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
281905bd
Commit
281905bd
authored
Jun 07, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提取空行问题处理
parent
5e46577f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
+13
-14
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
View file @
281905bd
...
@@ -131,8 +131,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -131,8 +131,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
{
{
dataFirstRowNum
=
point
.
DataFirstRowNum
.
Value
;
dataFirstRowNum
=
point
.
DataFirstRowNum
.
Value
;
RemoveIncomeRow
(
sheet
,
point
);
RemoveIncomeRow
(
sheet
,
point
);
WriteSheetIncomeData
(
sheet
,
columnHeader
,
point
,
style
,
headers
,
data
,
rows
,
dataFirstRowNum
);
var
endRowNum
=
WriteSheetIncomeData
(
sheet
,
columnHeader
,
point
,
style
,
headers
,
data
,
rows
,
dataFirstRowNum
);
dataFirstRowNum
=
point
.
DataFirstRowNum
.
Value
+
rows
.
Count
;
dataFirstRowNum
=
endRowNum
;
}
}
if
(
data
==
null
||
!
data
.
Any
())
return
;
if
(
data
==
null
||
!
data
.
Any
())
return
;
...
@@ -186,11 +186,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -186,11 +186,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
//数据为空,且单元格值不为空,不写入数据(保留原始值)
//数据为空,且单元格值不为空,不写入数据(保留原始值)
// 22.3.29 ry 只要是提取的列头全部覆盖数据
// 22.3.29 ry 只要是提取的列头全部覆盖数据
//if (value.HasValue && value != 0)
if
(
headers
!=
null
&&
headers
.
Contains
(
column
)
&&
value
.
HasValue
&&
value
!=
0
)
if
(
headers
!=
null
&&
headers
.
Contains
(
column
))
{
{
cell
.
SetCellValue
<
decimal
>(
value
??
0
);
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
CellStyle
=
cellStyle
;
cell
.
CellStyle
=
cellStyle
;
}
}
}
}
...
@@ -231,7 +229,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -231,7 +229,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
foreach
(
string
department
in
departments
)
foreach
(
string
department
in
departments
)
{
{
var
deptData
=
data
.
Where
(
t
=>
(
t
.
Department
??
""
)
==
department
);
var
deptData
=
data
.
Where
(
t
=>
(
t
.
Department
??
""
)
==
department
);
if
(
deptData
!=
null
&&
deptData
.
Any
())
{
var
row
=
sheet
.
GetOrCreate
(
dataFirstRowNum
);
var
row
=
sheet
.
GetOrCreate
(
dataFirstRowNum
);
for
(
int
cellIndex
=
point
.
HeaderFirstCellNum
.
Value
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
for
(
int
cellIndex
=
point
.
HeaderFirstCellNum
.
Value
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
{
{
...
@@ -240,15 +239,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -240,15 +239,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
if
(
filed
.
ContainsKey
(
column
))
if
(
filed
.
ContainsKey
(
column
))
{
{
var
value
=
(
deptData
!=
null
&&
deptData
.
Any
())
?
filed
[
column
]?.
Invoke
(
deptData
.
First
())
:
""
;
var
value
=
filed
[
column
]?.
Invoke
(
deptData
.
First
())
;
cell
.
SetCellOValue
(
value
);
cell
.
SetCellOValue
(
value
);
cell
.
CellStyle
=
cellStyle
;
cell
.
CellStyle
=
cellStyle
;
}
}
else
if
(
sheetType
==
SheetType
.
Income
||
(
headers
!=
null
&&
headers
.
Contains
(
column
)))
else
if
(
sheetType
==
SheetType
.
Income
||
(
headers
!=
null
&&
headers
.
Contains
(
column
)))
{
{
var
value
=
(
deptData
!=
null
&&
deptData
.
Any
())
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
.
NoBlank
()
==
column
)?.
Value
;
?
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
.
NoBlank
()
==
column
)?.
Value
:
0
;
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
CellStyle
=
cellStyle
;
cell
.
CellStyle
=
cellStyle
;
}
}
...
@@ -256,8 +253,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -256,8 +253,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
dataFirstRowNum
++;
dataFirstRowNum
++;
}
}
}
}
}
private
static
void
WriteSheetIncomeData
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
ExcelStyle
style
,
List
<
string
>
headers
,
private
static
int
WriteSheetIncomeData
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
ExcelStyle
style
,
List
<
string
>
headers
,
List
<
ExtractTransDto
>
data
,
List
<
IncomeRow
>
incomes
,
int
dataFirstRowNum
)
List
<
ExtractTransDto
>
data
,
List
<
IncomeRow
>
incomes
,
int
dataFirstRowNum
)
{
{
var
cellStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
数据
);
var
cellStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
数据
);
...
@@ -294,7 +292,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -294,7 +292,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
cell
.
SetCellValue
(
content
.
Value
);
cell
.
SetCellValue
(
content
.
Value
);
cell
.
CellStyle
=
cellStyle
;
cell
.
CellStyle
=
cellStyle
;
}
}
}
for
(
int
cellIndex
=
dataFirstCellNum
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
for
(
int
cellIndex
=
dataFirstCellNum
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
...
@@ -313,11 +311,12 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -313,11 +311,12 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
CellStyle
=
cellStyle
;
cell
.
CellStyle
=
cellStyle
;
}
}
dataFirstRowNum
++;
dataFirstRowNum
++;
data
.
RemoveAll
(
t
=>
t
.
Department
==
item
.
Department
);
data
.
RemoveAll
(
t
=>
t
.
Department
==
item
.
Department
);
}
}
}
}
return
dataFirstRowNum
;
}
public
static
string
HasValue
(
params
string
[]
list
)
public
static
string
HasValue
(
params
string
[]
list
)
{
{
...
...
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