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
c7bd4929
Commit
c7bd4929
authored
Oct 19, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
7b7e9c17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
6 deletions
+58
-6
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExcelHelper.cs
+32
-0
performance/Performance.Services/ExtractExcelService/SheetDataWrite/EmployeeDataWrite.cs
+26
-6
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExcelHelper.cs
View file @
c7bd4929
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
namespace
Performance.Services.ExtractExcelService
namespace
Performance.Services.ExtractExcelService
{
{
...
@@ -151,5 +152,36 @@ public static IWorkbook GetWorkbook(string filePath)
...
@@ -151,5 +152,36 @@ public static IWorkbook GetWorkbook(string filePath)
return
workbook
;
return
workbook
;
}
}
public
static
List
<
string
>
GetCellValues
(
this
IRow
row
)
{
List
<
string
>
list
=
new
List
<
string
>();
if
(
row
==
null
||
row
.
Cells
==
null
||
!
row
.
Cells
.
Any
())
return
list
;
list
=
row
.
Cells
.
Select
(
t
=>
t
.
GetDecodeEscapes
()).
ToList
();
return
list
;
}
public
static
Dictionary
<
string
,
int
>
GetCellIndex
(
this
IRow
row
,
params
string
[]
list
)
{
Dictionary
<
string
,
int
>
pairs
=
new
Dictionary
<
string
,
int
>();
if
(
row
==
null
||
row
.
Cells
==
null
||
!
row
.
Cells
.
Any
())
return
pairs
;
if
(
list
==
null
||
!
list
.
Any
())
return
pairs
;
var
columns
=
row
.
Cells
.
Select
(
t
=>
t
.
GetDecodeEscapes
()).
Distinct
().
ToList
();
foreach
(
string
key
in
list
)
{
if
(!
pairs
.
ContainsKey
(
key
)
&&
columns
.
Contains
(
key
))
{
pairs
.
Add
(
key
,
columns
.
IndexOf
(
key
));
}
}
return
pairs
;
}
}
}
}
}
performance/Performance.Services/ExtractExcelService/SheetDataWrite/EmployeeDataWrite.cs
View file @
c7bd4929
...
@@ -12,15 +12,35 @@ public class EmployeeDataWrite : ISheetDataWrite
...
@@ -12,15 +12,35 @@ public class EmployeeDataWrite : ISheetDataWrite
{
{
public
void
WriteSheetData
(
ISheet
sheet
,
PerSheetPoint
point
,
SheetType
sheetType
,
object
data
)
public
void
WriteSheetData
(
ISheet
sheet
,
PerSheetPoint
point
,
SheetType
sheetType
,
object
data
)
{
{
if
(
data
==
null
||
(
data
is
IEnumerable
<
per_employee
>
employees
&&
!
employees
.
Any
()))
return
;
if
(
data
is
IEnumerable
<
per_employee
>
employees
&&
employees
.
Any
(
t
=>
accountingUnits
.
Contains
(
t
.
UnitType
)))
{
int
dataFirstRowNum
=
point
.
DataFirstRowNum
.
Value
;
int
dataFirstRowNum
=
point
.
DataFirstRowNum
.
Value
;
var
columns
=
sheet
.
CreateRow
(
point
.
HeaderFirstRowNum
.
Value
).
GetCellValues
()
;
//foreach (var employee in employees)
foreach
(
var
employee
in
employees
)
//{
{
// var row = sheet.GetOrCreate(dataFirstRowNum);
var
row
=
sheet
.
GetOrCreate
(
dataFirstRowNum
);
for
(
int
cellIndex
=
0
;
cellIndex
<
columns
.
Count
();
cellIndex
++)
{
var
column
=
columns
[
cellIndex
];
if
(
string
.
IsNullOrEmpty
(
column
)
||
!
employeeDict
.
ContainsKey
(
column
))
continue
;
//}
var
cell
=
row
.
GetOrCreate
(
cellIndex
);
cell
.
SetCellOValue
(
employeeDict
[
column
].
Invoke
(
employee
));
}
dataFirstRowNum
++;
}
}
}
private
void
ClearHistoryData
(
ISheet
sheet
,
PerSheetPoint
point
,
List
<
per_employee
>
employees
,
List
<
string
>
columns
,
ref
int
dataFirstRowNum
)
{
foreach
(
var
employee
in
employees
)
{
var
row
=
sheet
.
GetRow
(
dataFirstRowNum
);
}
}
}
private
readonly
string
[]
accountingUnits
=
new
string
[]
{
AccountUnitType
.
行政高层
.
ToString
(),
AccountUnitType
.
行政中层
.
ToString
(),
AccountUnitType
.
行政工勤
.
ToString
()
};
private
readonly
string
[]
accountingUnits
=
new
string
[]
{
AccountUnitType
.
行政高层
.
ToString
(),
AccountUnitType
.
行政中层
.
ToString
(),
AccountUnitType
.
行政工勤
.
ToString
()
};
...
...
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