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
2c1dda0b
Commit
2c1dda0b
authored
Mar 10, 2022
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义提取,删除历史数据
parent
027b1210
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
+33
-2
performance/Performance.Services/ExtractExcelService/SheetDataWrite/CustomDataWrite.cs
+33
-2
No files found.
performance/Performance.Services/ExtractExcelService/SheetDataWrite/CustomDataWrite.cs
View file @
2c1dda0b
...
@@ -63,7 +63,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
...
@@ -63,7 +63,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
sheet
=
workbook
.
CreateSheet
(
module
.
ModuleName
);
sheet
=
workbook
.
CreateSheet
(
module
.
ModuleName
);
workbook
.
SetSheetOrder
(
sheet
.
SheetName
,
workbook
.
NumberOfSheets
-
1
);
workbook
.
SetSheetOrder
(
sheet
.
SheetName
,
workbook
.
NumberOfSheets
-
1
);
}
}
ClearSheetData
(
sheet
);
var
exscript
=
exscripts
.
FirstOrDefault
(
t
=>
t
.
TypeId
==
module
.
TypeId
);
var
exscript
=
exscripts
.
FirstOrDefault
(
t
=>
t
.
TypeId
==
module
.
TypeId
);
if
(
exscript
==
null
)
continue
;
if
(
exscript
==
null
)
continue
;
...
@@ -76,9 +76,10 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
...
@@ -76,9 +76,10 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
try
try
{
{
// 没数据跳过
// 没数据跳过
if
(
dynamics
==
null
||
dynamics
.
Count
()
==
0
)
if
(
dynamics
==
null
||
!
dynamics
.
Any
()
)
continue
;
continue
;
logger
.
LogInformation
(
$"
{
module
.
ModuleName
}
开始写入数据,
{
dynamics
.
Count
()}
"
);
var
first
=
(
IDictionary
<
string
,
object
>)
dynamics
.
ElementAt
(
0
);
var
first
=
(
IDictionary
<
string
,
object
>)
dynamics
.
ElementAt
(
0
);
var
header
=
sheet
.
GetOrCreate
(
Point
.
HeaderFirstRowNum
.
Value
);
var
header
=
sheet
.
GetOrCreate
(
Point
.
HeaderFirstRowNum
.
Value
);
if
(
header
!=
null
)
if
(
header
!=
null
)
...
@@ -116,5 +117,35 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
...
@@ -116,5 +117,35 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
}
}
}
}
}
}
private
void
ClearSheetData
(
ISheet
sheet
)
{
try
{
for
(
int
i
=
Point
.
DataFirstRowNum
.
Value
;
i
<
sheet
.
LastRowNum
+
1
;
i
++)
{
var
row
=
sheet
.
GetRow
(
i
);
if
(
row
!=
null
)
{
row
.
ZeroHeight
=
false
;
//取消隐藏行
int
dataFirstCellRowNum
=
Point
.
DataFirstCellNum
.
Value
;
//跳过核算单元和科室
for
(
int
j
=
dataFirstCellRowNum
;
j
<
row
.
LastCellNum
;
j
++)
{
var
cell
=
row
.
GetCell
(
j
);
if
(
cell
!=
null
&&
cell
.
CellType
!=
CellType
.
Formula
)
{
cell
.
RemoveCellComment
();
row
.
RemoveCell
(
cell
);
}
}
}
}
}
catch
(
Exception
ex
)
{
logger
.
LogError
(
ex
.
Message
);
}
}
}
}
}
}
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