using OfficeOpenXml; using System.IO; public static class ExportHelper { public static void ExportBubblePoint(BubblePointEntity entity, string filePath) { using var package = new ExcelPackage(); var sheet = package.Workbook.Worksheets.Add("泡点法测试"); sheet.Cells["A1"].Value = "工位"; sheet.Cells["B1"].Value = entity.StationId; sheet.Cells["A2"].Value = "测试日期"; sheet.Cells["B2"].Value = entity.TestDate.ToString("yyyy-MM-dd HH:mm:ss"); sheet.Cells["A3"].Value = "测试者"; sheet.Cells["B3"].Value = entity.Tester; sheet.Cells["A4"].Value = "样品类型"; sheet.Cells["B4"].Value = entity.SampleType; sheet.Cells["A5"].Value = "规格"; sheet.Cells["B5"].Value = entity.SampleSpec; sheet.Cells["A6"].Value = "室温(°C)"; sheet.Cells["B6"].Value = entity.RoomTemperature; sheet.Cells["A7"].Value = "浸润时间(h)"; sheet.Cells["B7"].Value = entity.SoakingTime; sheet.Cells["A8"].Value = "测试液体"; sheet.Cells["B8"].Value = entity.LiquidName; sheet.Cells["A9"].Value = "液体生产厂家"; sheet.Cells["B9"].Value = entity.LiquidManufacturer; sheet.Cells["A10"].Value = "泡点压力"; sheet.Cells["B10"].Value = $"{entity.BubblePointPressure} {entity.PressureUnit}"; sheet.Cells["A11"].Value = "最大孔径(μm)"; sheet.Cells["B11"].Value = entity.MaxPoreSize; package.SaveAs(new FileInfo(filePath)); } public static void ExportPoreDistribution(PoreDistributionEntity entity, string filePath) { using var package = new ExcelPackage(); var sheet = package.Workbook.Worksheets.Add("孔分布测试"); sheet.Cells["A1"].Value = "工位"; sheet.Cells["B1"].Value = entity.StationId; sheet.Cells["A2"].Value = "测试日期"; sheet.Cells["B2"].Value = entity.TestDate.ToString("yyyy-MM-dd HH:mm:ss"); sheet.Cells["A3"].Value = "测试者"; sheet.Cells["B3"].Value = entity.Tester; sheet.Cells["A4"].Value = "样品类型"; sheet.Cells["B4"].Value = entity.SampleType; sheet.Cells["A5"].Value = "规格"; sheet.Cells["B5"].Value = entity.SampleSpec; sheet.Cells["A6"].Value = "室温(°C)"; sheet.Cells["B6"].Value = entity.RoomTemperature; sheet.Cells["A7"].Value = "浸润时间(h)"; sheet.Cells["B7"].Value = entity.SoakingTime; sheet.Cells["A8"].Value = "测试液体"; sheet.Cells["B8"].Value = entity.LiquidName; sheet.Cells["A9"].Value = "液体生产厂家"; sheet.Cells["B9"].Value = entity.LiquidManufacturer; sheet.Cells["A10"].Value = "泡点压力"; sheet.Cells["B10"].Value = $"{entity.BubblePointPressure} {entity.PressureUnit}"; sheet.Cells["A11"].Value = "平均孔径(μm)"; sheet.Cells["B11"].Value = entity.AveragePoreSize; // 数据点表格 sheet.Cells["A13"].Value = "压力"; sheet.Cells["B13"].Value = "湿膜流量(L/min)"; sheet.Cells["C13"].Value = "干膜流量(L/min)"; int row = 14; foreach (var dp in entity.DataPoints) { sheet.Cells[$"A{row}"].Value = dp.Pressure; sheet.Cells[$"B{row}"].Value = dp.WetFlow; sheet.Cells[$"C{row}"].Value = dp.DryFlow; row++; } package.SaveAs(new FileInfo(filePath)); } }