update export style
This commit is contained in:
parent
b3b931e89f
commit
3a3d128ab0
@ -19,6 +19,7 @@ using System.Linq;
|
|||||||
using NPOI.SS.Formula.Functions;
|
using NPOI.SS.Formula.Functions;
|
||||||
using AIProofread.Model;
|
using AIProofread.Model;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using NPOI.SS.Util;
|
||||||
|
|
||||||
namespace AIProofread
|
namespace AIProofread
|
||||||
{
|
{
|
||||||
@ -593,6 +594,7 @@ namespace AIProofread
|
|||||||
simHeiFont.Color = NPOI.HSSF.Util.HSSFColor.Black.Index;
|
simHeiFont.Color = NPOI.HSSF.Util.HSSFColor.Black.Index;
|
||||||
// 设置表格样式
|
// 设置表格样式
|
||||||
var style = CreateBaseCellStyle(book);
|
var style = CreateBaseCellStyle(book);
|
||||||
|
style.FillPattern = FillPattern.NoFill; // SolidForeground
|
||||||
/* 系统与正文用不同字体区分(包括顶部栏、处理列、新增、删除等提示)勘误表系统字体为黑体,所有字号统一 */
|
/* 系统与正文用不同字体区分(包括顶部栏、处理列、新增、删除等提示)勘误表系统字体为黑体,所有字号统一 */
|
||||||
style.SetFont(simHeiFont);
|
style.SetFont(simHeiFont);
|
||||||
style.BorderBottom = NPOI.SS.UserModel.BorderStyle.None;
|
style.BorderBottom = NPOI.SS.UserModel.BorderStyle.None;
|
||||||
@ -620,14 +622,43 @@ namespace AIProofread
|
|||||||
CreateCell(row, 5, simHeiFont, "建议");
|
CreateCell(row, 5, simHeiFont, "建议");
|
||||||
CreateCell(row, 6, simHeiFont, "处理状态");
|
CreateCell(row, 6, simHeiFont, "处理状态");
|
||||||
|
|
||||||
|
|
||||||
|
// 设置表头筛选及冻结
|
||||||
|
sheet.CreateFreezePane(0, 1,0,1);
|
||||||
|
sheet.SetAutoFilter(CellRangeAddress.ValueOf("A1:G1"));
|
||||||
|
|
||||||
|
// 设置表头背景颜色为黑色
|
||||||
|
var headerStyle = CreateBaseCellStyle(book);
|
||||||
|
var headerFont = CreateBaseFont(book, "黑体", 11);
|
||||||
|
|
||||||
|
headerFont.Color = NPOI.HSSF.Util.HSSFColor.White.Index;
|
||||||
|
headerStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Black.Index;
|
||||||
|
headerStyle.FillPattern = FillPattern.SolidForeground;
|
||||||
|
headerStyle.SetFont(headerFont);
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
var cell = row.Cells[i];
|
||||||
|
cell.CellStyle = headerStyle;
|
||||||
|
//cell.CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
|
||||||
|
//// 设置背景
|
||||||
|
//cell.CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
|
||||||
|
//cell.CellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index;
|
||||||
|
//cell.CellStyle.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Black.Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//sheet.AutoFilter = new NPOI.SS.Util.AutoFilter(0, 0, new NPOI.SS.Util.AreaReference("A1:G1"));
|
||||||
|
|
||||||
|
|
||||||
// 设置宽度
|
// 设置宽度
|
||||||
|
sheet.SetColumnWidth(0, 0); // 详细信息
|
||||||
sheet.SetColumnWidth(3, 80 * 256); // 详细信息
|
sheet.SetColumnWidth(3, 80 * 256); // 详细信息
|
||||||
sheet.SetColumnWidth(4, 15 * 256); // 异常
|
sheet.SetColumnWidth(4, 20 * 256); // 异常
|
||||||
sheet.SetColumnWidth(5, 15 * 256); // 建议
|
sheet.SetColumnWidth(5, 20 * 256); // 建议
|
||||||
sheet.SetColumnWidth(6, 8 * 256); // 建议
|
sheet.SetColumnWidth(6, 10 * 256); // 处理状态
|
||||||
|
|
||||||
var blackFont = CreateBaseFont(book, NPOI.HSSF.Util.HSSFColor.Black.Index);
|
var blackFont = CreateBaseFont(book, NPOI.HSSF.Util.HSSFColor.Black.Index);
|
||||||
|
|
||||||
var redFont = CreateBaseFont(book, NPOI.HSSF.Util.HSSFColor.Red.Index);
|
var redFont = CreateBaseFont(book, NPOI.HSSF.Util.HSSFColor.Red.Index);
|
||||||
|
|
||||||
// 获取排序后的数据
|
// 获取排序后的数据
|
||||||
@ -780,7 +811,7 @@ namespace AIProofread
|
|||||||
// 保存到文件
|
// 保存到文件
|
||||||
book.Write(fs);
|
book.Write(fs);
|
||||||
//Globals.ThisAddIn.ShowMessage("导出成功", 3000);
|
//Globals.ThisAddIn.ShowMessage("导出成功", 3000);
|
||||||
Globals.ThisAddIn.ActiveDocument?.ShowMessage("导出勘误表成功", 3000, false);
|
Globals.ThisAddIn.ActiveDocument?.ShowMessage("导出勘误表成功", 2000, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user