diff --git a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs index 4a4e4c51..565e604f 100644 --- a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs +++ b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs @@ -322,7 +322,7 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule /// /// 部分 Office 版本会将可选小数格式(例如 #,##0.##)错误显示为 20,000.。 /// 互换估值中的这些列是展示字段,不参与 Excel 公式计算,因此在模板替换完成后写为已格式化文本, - /// 既保留去尾零口径,也避免留下孤立的小数点。 + /// 以遵守各字段的去尾零或固定小数位展示口径,且避免留下孤立的小数点。 /// private static void FormatSwapValuationDisplayCells(IEnumerable sheets, IEnumerable positions) { @@ -343,6 +343,10 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule SetTrimmedExcelText(worksheet.Cells[row, 10], item.PeriodAmount, 2); SetTrimmedExcelText(worksheet.Cells[row, 11], item.DividendAmount, 2); SetTrimmedExcelText(worksheet.Cells[row, 13], item.InitYtm, 4, percent: true); + // 浮动利率(绝对)和预付金利率要求固定保留四位小数,不去尾零。 + // 模板首列为空白占位列,渲染后的工作表会移除该列;最终文件中两列分别为 P、T。 + SetFixedExcelText(worksheet.Cells[row, 16], item.FloatRateAbs, 4, percent: true); + SetFixedExcelText(worksheet.Cells[row, 20], item.OpenMarginRate, 4, percent: true); } var totalRow = dataStartRow + positionList.Count; @@ -366,6 +370,20 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule cell.Style.Numberformat.Format = "@"; } + private static void SetFixedExcelText(ExcelRange cell, decimal? value, int decimalPlaces, bool percent = false) + { + if (!value.HasValue) + { + cell.Value = null; + return; + } + + var displayValue = percent ? value.Value * 100m : value.Value; + var text = displayValue.ToString("F" + decimalPlaces, CultureInfo.InvariantCulture); + cell.Value = percent ? text + "%" : text; + cell.Style.Numberformat.Format = "@"; + } + /// /// 财务状况 ///