From 46f1d0b8db41d333c3479eaea6471d69cd660bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Thu, 16 Jul 2026 20:53:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(report):=20=E6=9B=B4=E6=96=B0=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E6=8A=A5=E5=91=8A=E6=9C=8D=E5=8A=A1=E7=9A=84=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E4=BD=8D=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改注释说明以明确去尾零和固定小数位的展示要求 - 添加浮动利率和预付金利率的固定四位小数格式化功能 - 新增SetFixedExcelText方法用于固定小数位数显示 - 确保百分比数据正确应用四位小数格式化 --- .../SettlementReportFotShanXiService.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 = "@"; + } + /// /// 财务状况 ///