需要对 excel range中的所有行执行autofit columns,但是执行后,并不是全部column的字体都能完全显示。
Excel before:
image.png (4.2 KB)
Excel After:
image.png (10.1 KB)
Code:
ReportParameter param = parameter as ReportParameter;
string template = string.Empty;
template = param.HttpContext.Server.MapPath($"~/Templates/Pages/Test{Con_Report.Excel_Extension}");
string filePath = param.HttpContext.Server.MapPath($"~/Temp/{Guid.NewGuid().ToString()}{Con_Report.Excel_Extension}");
Helper.CopyFile(template, filePath);
using (IExcel excel = ExcelFactory.GetExcel(filePath))
{
Worksheet worksheet = excel.ActiveWorkSheet(0);
worksheet.Name = "Test";
worksheet.AutoFitColumns(0,0,14,8);
excel.Save(filePath);
}