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
9b5db502
Commit
9b5db502
authored
Oct 27, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加数据样式
parent
2eaef9e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
30 deletions
+36
-30
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
+36
-30
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
View file @
9b5db502
...
...
@@ -99,46 +99,47 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
private
static
void
WriteSheetDataExistent
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
SheetType
sheetType
,
ExcelStyle
style
,
List
<
string
>
headers
,
List
<
ExtractTransDto
>
data
,
ref
int
dataFirstRowNum
)
{
if
(
sheet
.
LastRowNum
>
dataFirstRowNum
)
{
int
dataFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
if
(
sheet
.
LastRowNum
<=
dataFirstRowNum
)
return
;
for
(
int
rowIndex
=
dataFirstRowNum
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
{
var
row
=
sheet
.
GetRow
(
rowIndex
);
if
(
row
==
null
)
continue
;
var
cellStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
数据
);
string
department
=
row
.
GetOrCreate
(
dataFirstCellNum
-
1
).
GetDecodeEscapes
();
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
int
dataFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
for
(
int
rowIndex
=
dataFirstRowNum
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
{
var
row
=
sheet
.
GetRow
(
rowIndex
);
if
(
row
==
null
)
continue
;
for
(
int
cellIndex
=
dataFirstCellNum
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
{
var
column
=
columnHeader
.
GetOrCreate
(
cellIndex
).
GetDecodeEscapes
();
var
cell
=
row
.
GetOrCreate
(
cellIndex
);
string
department
=
row
.
GetOrCreate
(
dataFirstCellNum
-
1
).
GetDecodeEscapes
();
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
==
column
)?.
Value
;
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
if
(
sheetType
==
SheetType
.
Income
)
{
cell
.
SetCellOValue
(
value
);
// 添加 style
}
else
if
(
cell
.
CellType
!=
CellType
.
Formula
)
for
(
int
cellIndex
=
dataFirstCellNum
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
{
var
column
=
columnHeader
.
GetOrCreate
(
cellIndex
).
GetDecodeEscapes
();
var
cell
=
row
.
GetOrCreate
(
cellIndex
);
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
==
column
)?.
Value
;
if
(
sheetType
==
SheetType
.
Income
)
{
cell
.
SetCellOValue
(
value
);
cell
.
CellStyle
=
cellStyle
;
}
else
if
(
cell
.
CellType
!=
CellType
.
Formula
)
{
cell
.
SetCellOValue
(
value
);
if
(
headers
!=
null
&&
headers
.
Contains
(
column
))
{
cell
.
SetCellOValue
(
value
);
if
(
headers
!=
null
&&
headers
.
Contains
(
column
))
{
// 是新增项,且该抽取数据在新增项中 添加style
}
cell
.
CellStyle
=
cellStyle
;
}
}
data
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
if
(
rowIndex
>
dataFirstRowNum
)
dataFirstRowNum
=
rowIndex
+
1
;
}
data
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
if
(
rowIndex
>
dataFirstRowNum
)
dataFirstRowNum
=
rowIndex
+
1
;
}
}
...
...
@@ -153,6 +154,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
filed
=
sheet
.
SheetName
.
Contains
(
"医生"
)
?
fieldDoctor
:
fieldNurse
;
}
var
deptStyle
=
style
.
GetCellStyle
();
var
cellStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
数据
);
foreach
(
string
department
in
departments
)
{
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
...
...
@@ -167,11 +171,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
if
(
filed
.
ContainsKey
(
column
))
{
cell
.
SetCellOValue
(
filed
[
column
]?.
Invoke
(
deptData
.
First
()));
cell
.
CellStyle
=
deptStyle
;
}
else
if
(
sheetType
==
SheetType
.
Income
||
(
headers
!=
null
&&
headers
.
Contains
(
column
)))
{
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
==
column
)?.
Value
;
cell
.
SetCellOValue
(
value
);
cell
.
CellStyle
=
cellStyle
;
}
}
dataFirstRowNum
++;
...
...
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