62,046
社区成员
发帖
与我相关
我的任务
分享
private void SetCellForeColorForTag(ISheet sheet, int modelIdx)
{
int mod = modelIdx % 3;
int[] colIdxs = new int[] { 1, 3, 5, 7, 9, 11, 13, 15 };
int colIdx = colIdxs[modelIdx / 3];
int startRowIdx = mod * 9;
int endRowIdx = (mod + 1) * 9;
IFont font = sheet.Workbook.CreateFont();
font.Color = (short)FontColor.NORMAL;
for (int i = startRowIdx; i < endRowIdx; i++)
{
//我这里故意写死看效果 begin//////////////////////////////////////////
IRow row = sheet.GetRow(0);
row.GetCell(1).CellStyle.SetFont(font);
//我这里故意写死看效果 end//////////////////////////////////////////
}
}
/// <summary>
/// 在流标签与骨髓标签的字体设置黑色
/// </summary>
/// <param name="sheet"></param>
/// <param name="modelIdx"></param>
private void SetCellForeColorForTag(ISheet sheet, int modelIdx, ICellStyle newStyle)
{
int mod = modelIdx % 3;
int[] colIdxs = new int[] { 1, 3, 5, 7, 9, 11, 13, 15 };
int colIdx = colIdxs[modelIdx / 3];
int startRowIdx = mod * 9;
int endRowIdx = (mod + 1) * 9;
//var newStyle = sheet.Workbook.CreateCellStyle();
//IFont font = sheet.Workbook.CreateFont();
//font.Color = (short)FontColor.RED;
//row.GetCell(1).CellStyle = newStyle;
//newStyle.SetFont(font);
for (int i = startRowIdx; i < endRowIdx; i++)
{
IRow row = sheet.GetRow(i);
row.GetCell(colIdx).CellStyle = newStyle;
}
}
这样就可以,的确需要重新设置 style