关键事项导出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.SetCellValue(tb.Rows[j]["GJSXTypeName"].ToString());
cell = row.CreateCell(6);
var stateCellStyle = cellStyle;
//if (state == "0")
//{
// stateCellStyle.FillForegroundColor = IndexedColors.Green.Index;
// //stateCellStyle.FillBackgroundColor = IndexedColors.Green.Index;
//}
//else if (state == "2" || state == "3")
//{
// //stateCellStyle.FillForegroundColor = IndexedColors.Blue.Index;
// stateCellStyle.FillBackgroundColor = IndexedColors.Blue.Index;
//}
//else if (state == "4")
//{
// //stateCellStyle.FillForegroundColor = IndexedColors.Red.Index;
// stateCellStyle.FillBackgroundColor = IndexedColors.Red.Index;
//}
NPOI.SS.UserModel.ICellStyle stateCellStyle = workbook.CreateCellStyle();
stateCellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
stateCellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
stateCellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
stateCellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
stateCellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
stateCellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
stateCellStyle.WrapText = true;
stateCellStyle.SetFont(font);
if (state == "0")
{
stateCellStyle.FillForegroundColor = IndexedColors.Green.Index;
stateCellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
}
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.SetCellValue(tb.Rows[j]["StateStr"].ToString());
cell = row.CreateCell(7);