2026-03-02 18:50:30 +08:00
|
|
|
|
using OfficeOpenXml;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
|
|
public static class ExportHelper
|
|
|
|
|
|
{
|
2026-03-31 20:17:17 +08:00
|
|
|
|
static ExportHelper()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 设置许可上下文为非商业用途(开源项目/个人学习)
|
|
|
|
|
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
|
|
|
|
|
}
|
2026-03-02 18:50:30 +08:00
|
|
|
|
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));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-07 14:47:36 +08:00
|
|
|
|
//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));
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
2026-03-02 18:50:30 +08:00
|
|
|
|
public static void ExportPoreDistribution(PoreDistributionEntity entity, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
using var package = new ExcelPackage();
|
|
|
|
|
|
|
2026-04-07 14:47:36 +08:00
|
|
|
|
// 公共信息工作表(可选)
|
|
|
|
|
|
var infoSheet = package.Workbook.Worksheets.Add("测试信息");
|
|
|
|
|
|
infoSheet.Cells["A1"].Value = "工位"; infoSheet.Cells["B1"].Value = entity.StationId;
|
|
|
|
|
|
infoSheet.Cells["A2"].Value = "测试日期"; infoSheet.Cells["B2"].Value = entity.TestDate.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
infoSheet.Cells["A3"].Value = "测试者"; infoSheet.Cells["B3"].Value = entity.Tester;
|
|
|
|
|
|
infoSheet.Cells["A4"].Value = "样品类型"; infoSheet.Cells["B4"].Value = entity.SampleType;
|
|
|
|
|
|
infoSheet.Cells["A5"].Value = "规格"; infoSheet.Cells["B5"].Value = entity.SampleSpec;
|
|
|
|
|
|
infoSheet.Cells["A6"].Value = "室温(°C)"; infoSheet.Cells["B6"].Value = entity.RoomTemperature;
|
|
|
|
|
|
infoSheet.Cells["A7"].Value = "浸润时间(h)"; infoSheet.Cells["B7"].Value = entity.SoakingTime;
|
|
|
|
|
|
infoSheet.Cells["A8"].Value = "测试液体"; infoSheet.Cells["B8"].Value = entity.LiquidName;
|
|
|
|
|
|
infoSheet.Cells["A9"].Value = "液体生产厂家"; infoSheet.Cells["B9"].Value = entity.LiquidManufacturer;
|
|
|
|
|
|
infoSheet.Cells["A10"].Value = "压力单位"; infoSheet.Cells["B10"].Value = entity.PressureUnit;
|
|
|
|
|
|
infoSheet.Cells["A11"].Value = "平均孔径(μm)"; infoSheet.Cells["B11"].Value = entity.AveragePoreSize;
|
|
|
|
|
|
|
|
|
|
|
|
// 湿膜数据表(仅保留湿膜流量 > 0 的点)
|
|
|
|
|
|
var wetPoints = entity.DataPoints.Where(dp => dp.WetFlow > 0).OrderBy(dp => dp.Pressure).ToList();
|
|
|
|
|
|
if (wetPoints.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
var wetSheet = package.Workbook.Worksheets.Add("湿膜数据");
|
|
|
|
|
|
wetSheet.Cells["A1"].Value = "压力";
|
|
|
|
|
|
wetSheet.Cells["B1"].Value = "湿膜流量(L/min)";
|
|
|
|
|
|
int row = 2;
|
|
|
|
|
|
foreach (var dp in wetPoints)
|
|
|
|
|
|
{
|
|
|
|
|
|
wetSheet.Cells[$"A{row}"].Value = dp.Pressure;
|
|
|
|
|
|
wetSheet.Cells[$"B{row}"].Value = dp.WetFlow;
|
|
|
|
|
|
row++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 干膜数据表(仅保留干膜流量 > 0 的点)
|
|
|
|
|
|
var dryPoints = entity.DataPoints.Where(dp => dp.DryFlow > 0).OrderBy(dp => dp.Pressure).ToList();
|
|
|
|
|
|
if (dryPoints.Any())
|
2026-03-02 18:50:30 +08:00
|
|
|
|
{
|
2026-04-07 14:47:36 +08:00
|
|
|
|
var drySheet = package.Workbook.Worksheets.Add("干膜数据");
|
|
|
|
|
|
drySheet.Cells["A1"].Value = "压力";
|
|
|
|
|
|
drySheet.Cells["B1"].Value = "干膜流量(L/min)";
|
|
|
|
|
|
int row = 2;
|
|
|
|
|
|
foreach (var dp in dryPoints)
|
|
|
|
|
|
{
|
|
|
|
|
|
drySheet.Cells[$"A{row}"].Value = dp.Pressure;
|
|
|
|
|
|
drySheet.Cells[$"B{row}"].Value = dp.DryFlow;
|
|
|
|
|
|
row++;
|
|
|
|
|
|
}
|
2026-03-02 18:50:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
package.SaveAs(new FileInfo(filePath));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|