关键事项导出excel,给状态栏位添加背景色

This commit is contained in:
夏菊 2025-03-26 10:51:04 +08:00
parent 0e7dae0099
commit 2852eb0656
1 changed files with 25 additions and 16 deletions

View File

@ -535,22 +535,31 @@ namespace FineUIPro.Web.PZHGL.GJSX
cell.CellStyle = cellStyle; cell.CellStyle = cellStyle;
cell.SetCellValue(tb.Rows[j]["GJSXTypeName"].ToString()); cell.SetCellValue(tb.Rows[j]["GJSXTypeName"].ToString());
cell = row.CreateCell(6); cell = row.CreateCell(6);
var stateCellStyle = cellStyle;
//if (state == "0") NPOI.SS.UserModel.ICellStyle stateCellStyle = workbook.CreateCellStyle();
//{ stateCellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
// stateCellStyle.FillForegroundColor = IndexedColors.Green.Index; stateCellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
// //stateCellStyle.FillBackgroundColor = IndexedColors.Green.Index; stateCellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
//} stateCellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
//else if (state == "2" || state == "3") stateCellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
//{ stateCellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
// //stateCellStyle.FillForegroundColor = IndexedColors.Blue.Index; stateCellStyle.WrapText = true;
// stateCellStyle.FillBackgroundColor = IndexedColors.Blue.Index; stateCellStyle.SetFont(font);
//} if (state == "0")
//else if (state == "4") {
//{ stateCellStyle.FillForegroundColor = IndexedColors.Green.Index;
// //stateCellStyle.FillForegroundColor = IndexedColors.Red.Index; stateCellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
// stateCellStyle.FillBackgroundColor = IndexedColors.Red.Index; }
//} else if (state == "2" || state == "3")
{
stateCellStyle.FillForegroundColor = IndexedColors.SkyBlue.Index;
stateCellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
}
else if (state == "4")
{
stateCellStyle.FillForegroundColor = IndexedColors.Red.Index;
stateCellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
}
cell.CellStyle = stateCellStyle; cell.CellStyle = stateCellStyle;
cell.SetCellValue(tb.Rows[j]["StateStr"].ToString()); cell.SetCellValue(tb.Rows[j]["StateStr"].ToString());
cell = row.CreateCell(7); cell = row.CreateCell(7);