This commit is contained in:
GukSang.Jin
2025-12-31 18:45:00 +08:00
parent bfe86db6bf
commit 04889abac2

View File

@@ -257,6 +257,15 @@ namespace WindowsFormsApp6
private void CreateInfoSection(ISheet sheet, ref int currentRow, int sampleCount,
(ICellStyle titleStyle, ICellStyle headerStyle, ICellStyle dataStyle, ICellStyle yellowStyle) styles)
{
// 从界面获取实际数据
string sampleName = textBox1.Text.Trim();
string materialCode = textBox2.Text.Trim();
string batchNumber = textBox3.Text.Trim();
string operatorName = textBox4.Text.Trim();
string instrument = textBox5.Text.Trim();
string deviceNumber = textBox6.Text.Trim();
string testTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
// 第一行信息
IRow infoRow1 = sheet.CreateRow(currentRow++);
infoRow1.Height = 400;
@@ -267,7 +276,7 @@ namespace WindowsFormsApp6
cell1.CellStyle = styles.dataStyle;
ICell cell2 = infoRow1.CreateCell(1);
cell2.SetCellValue("手动录入");
cell2.SetCellValue(string.IsNullOrEmpty(sampleName) ? "" : sampleName);
cell2.CellStyle = styles.yellowStyle;
// 为合并区域的所有单元格设置样式
infoRow1.CreateCell(2).CellStyle = styles.yellowStyle;
@@ -279,7 +288,7 @@ namespace WindowsFormsApp6
cell3.CellStyle = styles.dataStyle;
ICell cell4 = infoRow1.CreateCell(4);
cell4.SetCellValue("手动录入");
cell4.SetCellValue(string.IsNullOrEmpty(materialCode) ? "" : materialCode);
cell4.CellStyle = styles.yellowStyle;
// 为合并区域的所有单元格设置样式
infoRow1.CreateCell(5).CellStyle = styles.yellowStyle;
@@ -291,7 +300,7 @@ namespace WindowsFormsApp6
cell5.CellStyle = styles.dataStyle;
ICell cell6 = infoRow1.CreateCell(7);
cell6.SetCellValue("手动录入");
cell6.SetCellValue(string.IsNullOrEmpty(batchNumber) ? "" : batchNumber);
cell6.CellStyle = styles.yellowStyle;
// 操作人员
@@ -300,7 +309,7 @@ namespace WindowsFormsApp6
cell7.CellStyle = styles.dataStyle;
ICell cell8 = infoRow1.CreateCell(9);
cell8.SetCellValue("手动录入");
cell8.SetCellValue(string.IsNullOrEmpty(operatorName) ? "" : operatorName);
cell8.CellStyle = styles.yellowStyle;
// 第二行信息
@@ -313,7 +322,7 @@ namespace WindowsFormsApp6
cell21.CellStyle = styles.dataStyle;
ICell cell22 = infoRow2.CreateCell(1);
cell22.SetCellValue("系统检测时间");
cell22.SetCellValue(testTime);
cell22.CellStyle = styles.yellowStyle;
// 为合并区域的所有单元格设置样式
infoRow2.CreateCell(2).CellStyle = styles.yellowStyle;
@@ -325,7 +334,7 @@ namespace WindowsFormsApp6
cell23.CellStyle = styles.dataStyle;
ICell cell24 = infoRow2.CreateCell(4);
cell24.SetCellValue("厂家仪器名称");
cell24.SetCellValue(string.IsNullOrEmpty(instrument) ? "" : instrument);
cell24.CellStyle = styles.yellowStyle;
// 为合并区域的所有单元格设置样式
infoRow2.CreateCell(5).CellStyle = styles.yellowStyle;
@@ -337,7 +346,7 @@ namespace WindowsFormsApp6
cell25.CellStyle = styles.dataStyle;
ICell cell26 = infoRow2.CreateCell(7);
cell26.SetCellValue("手动录入");
cell26.SetCellValue(string.IsNullOrEmpty(deviceNumber) ? "" : deviceNumber);
cell26.CellStyle = styles.yellowStyle;
// 数据文件