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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
44 deletions
+43
-44
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
+43
-44
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,33 +229,33 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -231,33 +229,33 @@ 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
);
for
(
int
cellIndex
=
point
.
HeaderFirstCellNum
.
Value
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
{
{
var
column
=
columnHeader
.
GetCell
(
cellIndex
).
GetDecodeEscapes
()?.
Replace
(
"("
,
"("
).
Replace
(
")"
,
")"
);
;
var
row
=
sheet
.
GetOrCreate
(
dataFirstRowNum
);
var
cell
=
row
.
CreateCell
(
cellIndex
);
for
(
int
cellIndex
=
point
.
HeaderFirstCellNum
.
Value
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
if
(
filed
.
ContainsKey
(
column
))
{
var
value
=
(
deptData
!=
null
&&
deptData
.
Any
())
?
filed
[
column
]?.
Invoke
(
deptData
.
First
())
:
""
;
cell
.
SetCellOValue
(
value
);
cell
.
CellStyle
=
cellStyle
;
}
else
if
(
sheetType
==
SheetType
.
Income
||
(
headers
!=
null
&&
headers
.
Contains
(
column
)))
{
{
var
value
=
(
deptData
!=
null
&&
deptData
.
Any
())
var
column
=
columnHeader
.
GetCell
(
cellIndex
).
GetDecodeEscapes
()?.
Replace
(
"("
,
"("
).
Replace
(
")"
,
")"
);
;
?
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
.
NoBlank
()
==
column
)?.
Value
var
cell
=
row
.
CreateCell
(
cellIndex
);
:
0
;
cell
.
SetCellValue
<
decimal
>(
value
);
if
(
filed
.
ContainsKey
(
column
))
cell
.
CellStyle
=
cellStyle
;
{
var
value
=
filed
[
column
]?.
Invoke
(
deptData
.
First
());
cell
.
SetCellOValue
(
value
);
cell
.
CellStyle
=
cellStyle
;
}
else
if
(
sheetType
==
SheetType
.
Income
||
(
headers
!=
null
&&
headers
.
Contains
(
column
)))
{
var
value
=
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
.
NoBlank
()
==
column
)?.
Value
;
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
CellStyle
=
cellStyle
;
}
}
}
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,29 +292,30 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -294,29 +292,30 @@ 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
++)
{
var
column
=
columnHeader
.
GetOrCreate
(
cellIndex
).
GetDecodeEscapes
();
var
cell
=
row
.
GetOrCreate
(
cellIndex
);
var
value
=
(
deptData
!=
null
&&
deptData
.
Any
())
for
(
int
cellIndex
=
dataFirstCellNum
;
cellIndex
<
columnHeader
.
LastCellNum
;
cellIndex
++)
?
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
.
NoBlank
()
==
column
)?.
Value
{
:
0
;
var
column
=
columnHeader
.
GetOrCreate
(
cellIndex
).
GetDecodeEscapes
();
//if (cell.CellType != CellType.Formula)
var
cell
=
row
.
GetOrCreate
(
cellIndex
);
//{
// cell.SetCellValue<decimal>(value);
// cell.CellStyle = cellStyle;
//}
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
CellStyle
=
cellStyle
;
}
dataFirstRowNum
++;
var
value
=
(
deptData
!=
null
&&
deptData
.
Any
())
data
.
RemoveAll
(
t
=>
t
.
Department
==
item
.
Department
);
?
deptData
.
FirstOrDefault
(
t
=>
t
.
Category
.
NoBlank
()
==
column
)?.
Value
:
0
;
//if (cell.CellType != CellType.Formula)
//{
// cell.SetCellValue<decimal>(value);
// cell.CellStyle = cellStyle;
//}
cell
.
SetCellValue
<
decimal
>(
value
);
cell
.
CellStyle
=
cellStyle
;
}
dataFirstRowNum
++;
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