Commit 4483de48 by Licx

Merge branch 'release/v22.4.18-Beta-wuzhou' into develop

parents 60a4934c 846e58a9
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.SS.Formula;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
using Performance.DtoModels; using Performance.DtoModels;
...@@ -311,5 +312,30 @@ public static void EvaluateAll(this IWorkbook workbook) ...@@ -311,5 +312,30 @@ public static void EvaluateAll(this IWorkbook workbook)
return; return;
} }
} }
/// <summary>
/// 设置打开Excel时将更新公式
/// </summary>
/// <param name="workbook"></param>
public static void ForceFormulaRecalculation(this IWorkbook workbook)
{
try
{
if (workbook == null) return;
int index = 0;
while (index < workbook.NumberOfSheets)
{
var sheet = workbook.GetSheetAt(index);
index++;
sheet.ForceFormulaRecalculation = true;
}
}
catch
{
return;
}
}
} }
} }
using NPOI.HSSF.UserModel; using NPOI.SS.UserModel;
using NPOI.SS.Formula;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using OfficeOpenXml; using OfficeOpenXml;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -10,7 +7,6 @@ ...@@ -10,7 +7,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
namespace Performance.Services.ExtractExcelService namespace Performance.Services.ExtractExcelService
{ {
...@@ -158,22 +154,8 @@ public static void ClearSheetPartialData(ISheet sheet, PerSheetPoint point, Shee ...@@ -158,22 +154,8 @@ public static void ClearSheetPartialData(ISheet sheet, PerSheetPoint point, Shee
{ {
var cell = row.GetCell(j); var cell = row.GetCell(j);
if (cell == null) continue; if (cell == null) continue;
if (cell.CellType == CellType.Formula) if (cell.CellType != CellType.Formula || sheetType == SheetType.Income)
{
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(); cell.RemoveCellComment();
row.RemoveCell(cell); row.RemoveCell(cell);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
namespace Performance.Services.ExtractExcelService namespace Performance.Services.ExtractExcelService
{ {
......
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