|
|
|
@ -579,24 +579,25 @@ namespace TeacherExt.Controllers
|
|
|
|
|
foreach (var head in item.Headers)
|
|
|
|
|
{
|
|
|
|
|
var cell = (sheet.GetRow(i)??sheet.CreateRow(i)).CreateCell(colIndex);
|
|
|
|
|
cell.SetCellValue(head.Key);
|
|
|
|
|
var length = cell.ToString().Split('\n').Select(o => Encoding.UTF8.GetBytes(o).Count()).Max()*256;
|
|
|
|
|
if (length>sheet.GetColumnWidthInPixels(colIndex))
|
|
|
|
|
{
|
|
|
|
|
sheet.SetColumnWidth(colIndex, length);
|
|
|
|
|
}
|
|
|
|
|
cell.SetStyle(style).SetCellValue(head.Key);
|
|
|
|
|
//var length = cell.ToString().Split('\n').Select(o => Encoding.UTF8.GetBytes(o).Count()).Max()*256;
|
|
|
|
|
//if (length>sheet.GetColumnWidthInPixels(colIndex))
|
|
|
|
|
//{
|
|
|
|
|
// sheet.SetColumnWidth(colIndex, length);
|
|
|
|
|
//}
|
|
|
|
|
if (head.Value>1)
|
|
|
|
|
{
|
|
|
|
|
for (int j = i; j < head.Value; j++)
|
|
|
|
|
for (int j = i+1; j < head.Value; j++)
|
|
|
|
|
{
|
|
|
|
|
var row = sheet.GetRow(j) ?? sheet.CreateRow(j);
|
|
|
|
|
(row.GetCell(colIndex)??row.CreateCell(colIndex)).SetStyle(style);
|
|
|
|
|
}
|
|
|
|
|
sheet.AddMergedRegion(new CellRangeAddress(i,i+head.Value-1,colIndex,colIndex));
|
|
|
|
|
sheet.GetRow(i).GetCell(colIndex).SetStyle(style);
|
|
|
|
|
i = i + head.Value;
|
|
|
|
|
}
|
|
|
|
|
i = i + head.Value;
|
|
|
|
|
}
|
|
|
|
|
//sheet.AutoSizeColumn(colIndex);
|
|
|
|
|
colIndex += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|