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
189af943
Commit
189af943
authored
Jan 21, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首次抽取时,起始行列位置错误调整
parent
f184f938
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
+13
-11
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
View file @
189af943
...
@@ -34,17 +34,18 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
...
@@ -34,17 +34,18 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
// 去除excel中已存在的列
// 去除excel中已存在的列
int
headerFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
int
headerFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
if
(
columnHeader
.
LastCellNum
>
point
.
DataFirstCellNum
)
if
(
columnHeader
.
LastCellNum
>
point
.
DataFirstCellNum
.
Value
)
{
{
for
(
int
index
=
headerFirstCellNum
;
index
<
columnHeader
.
LastCellNum
;
index
++)
for
(
int
index
=
point
.
DataFirstCellNum
.
Value
;
index
<
columnHeader
.
LastCellNum
;
index
++)
{
{
var
column
=
columnHeader
.
GetCell
(
index
).
GetDecodeEscapes
();
var
column
=
columnHeader
.
GetCell
(
index
).
GetDecodeEscapes
();
if
(
string
.
IsNullOrEmpty
(
column
))
continue
;
if
(
string
.
IsNullOrEmpty
(
column
))
continue
;
if
(
index
>
headerFirstCellNum
)
headerFirstCellNum
=
index
;
columns
.
RemoveAll
(
t
=>
t
.
ColumnName
.
NoBlank
()
==
column
);
columns
.
RemoveAll
(
t
=>
t
.
ColumnName
.
NoBlank
()
==
column
);
if
(
index
>
headerFirstCellNum
)
headerFirstCellNum
=
index
+
1
;
}
}
if
(
headerFirstCellNum
>
point
.
DataFirstCellNum
.
Value
)
headerFirstCellNum
+=
1
;
}
}
if
(
columns
==
null
||
!
columns
.
Any
())
return
;
if
(
columns
==
null
||
!
columns
.
Any
())
return
;
...
@@ -53,7 +54,6 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
...
@@ -53,7 +54,6 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
:
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
系数
,
CellFormat
.
百分比
);
:
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
系数
,
CellFormat
.
百分比
);
var
columnStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
列头
);
var
columnStyle
=
style
.
SetBgkColorAndFormat
(
style
.
GetCellStyle
(),
StyleType
.
列头
);
headerFirstCellNum
+=
1
;
// 补充excel中不存在的列
// 补充excel中不存在的列
foreach
(
var
item
in
columns
)
foreach
(
var
item
in
columns
)
{
{
...
@@ -111,7 +111,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -111,7 +111,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
int
dataFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
int
dataFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
for
(
int
rowIndex
=
dataFirstRowNum
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
for
(
int
rowIndex
=
point
.
DataFirstRowNum
.
Value
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
{
{
var
row
=
sheet
.
GetRow
(
rowIndex
);
var
row
=
sheet
.
GetRow
(
rowIndex
);
if
(
row
==
null
)
continue
;
if
(
row
==
null
)
continue
;
...
@@ -119,6 +119,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -119,6 +119,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
string
department
=
row
.
GetOrCreate
(
dataFirstCellNum
-
1
).
GetDecodeEscapes
();
string
department
=
row
.
GetOrCreate
(
dataFirstCellNum
-
1
).
GetDecodeEscapes
();
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
if
(
rowIndex
>
dataFirstRowNum
)
dataFirstRowNum
=
rowIndex
;
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
...
@@ -146,8 +148,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -146,8 +148,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
}
}
data
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
data
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
if
(
rowIndex
>
dataFirstRowNum
)
dataFirstRowNum
=
rowIndex
+
1
;
}
}
dataFirstRowNum
+=
1
;
}
}
private
static
void
WriteSheetDataNonexistent
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
SheetType
sheetType
,
ExcelStyle
style
,
private
static
void
WriteSheetDataNonexistent
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
SheetType
sheetType
,
ExcelStyle
style
,
...
@@ -166,7 +168,6 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
...
@@ -166,7 +168,6 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
headers
=
headers
.
Select
(
t
=>
t
.
NoBlank
()).
ToList
();
headers
=
headers
.
Select
(
t
=>
t
.
NoBlank
()).
ToList
();
dataFirstRowNum
+=
1
;
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
);
...
@@ -266,7 +267,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
...
@@ -266,7 +267,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
int
dataFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
int
dataFirstCellNum
=
point
.
DataFirstCellNum
.
Value
;
for
(
int
rowIndex
=
dataFirstRowNum
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
for
(
int
rowIndex
=
point
.
DataFirstRowNum
.
Value
;
rowIndex
<
sheet
.
LastRowNum
+
1
;
rowIndex
++)
{
{
var
row
=
sheet
.
GetRow
(
rowIndex
);
var
row
=
sheet
.
GetRow
(
rowIndex
);
if
(
row
==
null
)
continue
;
if
(
row
==
null
)
continue
;
...
@@ -274,6 +275,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
...
@@ -274,6 +275,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
string
department
=
row
.
GetOrCreate
(
dataFirstCellNum
-
1
).
GetDecodeEscapes
();
string
department
=
row
.
GetOrCreate
(
dataFirstCellNum
-
1
).
GetDecodeEscapes
();
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
if
(
string
.
IsNullOrEmpty
(
department
))
continue
;
if
(
rowIndex
>
dataFirstRowNum
)
dataFirstRowNum
=
rowIndex
;
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
var
deptData
=
data
.
Where
(
t
=>
t
.
Department
==
department
);
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
if
(
deptData
==
null
||
!
deptData
.
Any
())
continue
;
...
@@ -300,8 +303,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
...
@@ -300,8 +303,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
}
}
data
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
data
.
RemoveAll
(
t
=>
t
.
Department
==
department
);
if
(
rowIndex
>
dataFirstRowNum
)
dataFirstRowNum
=
rowIndex
+
1
;
}
}
dataFirstRowNum
+=
1
;
}
}
private
static
void
WriteCollectDataNonexistent
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
SheetType
sheetType
,
ExcelStyle
style
,
private
static
void
WriteCollectDataNonexistent
(
ISheet
sheet
,
IRow
columnHeader
,
PerSheetPoint
point
,
SheetType
sheetType
,
ExcelStyle
style
,
...
@@ -318,7 +321,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
...
@@ -318,7 +321,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
headers
=
headers
.
Select
(
t
=>
t
.
NoBlank
()).
ToList
();
headers
=
headers
.
Select
(
t
=>
t
.
NoBlank
()).
ToList
();
dataFirstRowNum
+=
1
;
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
);
...
...
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