From f3df27995d2d7c845be616f7f366cb910bb6a64b Mon Sep 17 00:00:00 2001 From: sunhonglei Date: Fri, 13 Dec 2024 18:45:54 +0800 Subject: [PATCH] feat: --- ViewModel/Grading/GradingResultVM.cs | 43 ++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/ViewModel/Grading/GradingResultVM.cs b/ViewModel/Grading/GradingResultVM.cs index 3d6664c..efdea3e 100644 --- a/ViewModel/Grading/GradingResultVM.cs +++ b/ViewModel/Grading/GradingResultVM.cs @@ -661,17 +661,19 @@ public class GradingResultVM : BaseViewModel col = 0; dataRow = sheet.CreateRow(row); Measurements info = algorithmResult.measurements; - dataRow.CreateCell(col++).SetCellValue($"{info.M1}(mm)"); - dataRow.CreateCell(col++).SetCellValue($"{info.M2}(mm)"); - dataRow.CreateCell(col++).SetCellValue($"{info.M3}(mm)"); - dataRow.CreateCell(col++).SetCellValue($"{info.TABLE*100}%"); - dataRow.CreateCell(col++).SetCellValue($"{info.CROWN_HEIGHT * 100}%"); - dataRow.CreateCell(col++).SetCellValue($"{info.PAV_DEPTH * 100}%"); - dataRow.CreateCell(col++).SetCellValue($"{info.TOTAL_DEPTH * 100}%"); - dataRow.CreateCell(col++).SetCellValue($"{info.CROWN_ANGLE}°"); - dataRow.CreateCell(col++).SetCellValue($"{info.PAV_ANGLE}°"); - dataRow.CreateCell(col++).SetCellValue($"{info.CULET}(mm)"); - dataRow.CreateCell(col++).SetCellValue($"{info.GIRDLE * 100}%"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.M1)}(mm)"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.M2)}(mm)"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.M3)}(mm)"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.TABLE)}%"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.CROWN_HEIGHT)}%"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.PAV_DEPTH)}%"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.TOTAL_DEPTH)}%"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CROWN_ANGLE)}°"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.PAV_ANGLE)}°"); + // TODO 底尖直径 + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_A(info.CULET)}(mm)"); + dataRow.CreateCell(col++).SetCellValue($"{FormatDouble_P(info.GIRDLE)}%"); + // TODO 腰部厚度英文 dataRow.CreateCell(col++).SetCellValue($"{info.M1}"); dataRow.CreateCell(col++).SetCellValue($""); string sysmlevel = ""; @@ -687,7 +689,24 @@ public class GradingResultVM : BaseViewModel { workbook.Write(stream); } - + } + /// + /// 百分比用的小数格式化 + /// + /// + /// + private string FormatDouble_P(double value) + { + return (Math.Floor(value*1000)/10).ToString(digitsFormat); + } + /// + /// 直接值(角度,直径)用的小数格式化 + /// + /// + /// + private string FormatDouble_A(double value) + { + return (Math.Floor(value * 10) / 10).ToString(digitsFormat); } private void DatFile(string filePath) {