Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
846e58a9
Commit
846e58a9
authored
Aug 17, 2022
by
Licx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置打开Excel时将更新公式
parent
79095838
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
22 deletions
+29
-22
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExcelHelper.cs
+26
-0
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExtractHelper.cs
+3
-21
performance/Performance.Services/ExtractExcelService/ExtractService.cs
+0
-1
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExcelHelper.cs
View file @
846e58a9
using
NPOI.HSSF.UserModel
;
using
NPOI.SS.Formula
;
using
NPOI.SS.UserModel
;
using
NPOI.XSSF.UserModel
;
using
Performance.DtoModels
;
...
...
@@ -305,5 +306,30 @@ public static void EvaluateAll(this IWorkbook workbook)
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
;
}
}
}
}
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExtractHelper.cs
View file @
846e58a9
using
NPOI.HSSF.UserModel
;
using
NPOI.SS.Formula
;
using
NPOI.SS.UserModel
;
using
NPOI.XSSF.UserModel
;
using
NPOI.SS.UserModel
;
using
OfficeOpenXml
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
...
...
@@ -10,7 +7,6 @@
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
namespace
Performance.Services.ExtractExcelService
{
...
...
@@ -152,22 +148,8 @@ public static void ClearSheetPartialData(ISheet sheet, PerSheetPoint point, Shee
{
var
cell
=
row
.
GetCell
(
j
);
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
)
if
(
cell
.
CellType
!=
CellType
.
Formula
||
sheetType
==
SheetType
.
Income
)
{
cell
.
RemoveCellComment
();
row
.
RemoveCell
(
cell
);
...
...
performance/Performance.Services/ExtractExcelService/ExtractService.cs
View file @
846e58a9
...
...
@@ -11,7 +11,6 @@
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Linq.Expressions
;
namespace
Performance.Services.ExtractExcelService
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment