Commit 79095838 by Licx

清除数据时,公式重新计算 - 统一计算时出错会跳过

parent 56185588
using NPOI.SS.UserModel;
using NPOI.HSSF.UserModel;
using NPOI.SS.Formula;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using OfficeOpenXml;
using Performance.DtoModels;
using Performance.EntityModels;
......@@ -148,7 +151,23 @@ public static void ClearSheetPartialData(ISheet sheet, PerSheetPoint point, Shee
for (int j = dataFirstCellRowNum; j < row.LastCellNum; j++)
{
var cell = row.GetCell(j);
if (cell != null && (cell.CellType != CellType.Formula || sheetType == SheetType.Income))
if (cell == null) continue;
if (cell.CellType == CellType.Formula)
{
try
{
BaseFormulaEvaluator e = row.Sheet.Workbook is XSSFWorkbook
? new XSSFFormulaEvaluator(row.Sheet.Workbook)
: new HSSFFormulaEvaluator(row.Sheet.Workbook);
cell = e.EvaluateInCell(cell);
}
catch
{
continue;
}
}
else if (cell.CellType != CellType.Formula || sheetType == SheetType.Income)
{
cell.RemoveCellComment();
row.RemoveCell(cell);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment