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
f78291b1
Commit
f78291b1
authored
Feb 15, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
精简代码
parent
402df3e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
48 deletions
+46
-48
performance/Performance.Services/OnlineExcel/OnlineExcelService.Read.cs
+46
-48
No files found.
performance/Performance.Services/OnlineExcel/OnlineExcelService.Read.cs
View file @
f78291b1
...
...
@@ -105,64 +105,62 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
using
(
ExcelPackage
package
=
new
ExcelPackage
(
file
))
{
foreach
(
var
sheet
in
package
.
Workbook
.
Worksheets
)
{
if
(
sheet
.
Name
!=
sheetName
)
continue
;
var
sheet
=
package
.
Workbook
.
Worksheets
.
FirstOrDefault
(
w
=>
w
.
Name
==
sheetName
);
if
(
sheet
==
null
)
return
null
;
IEnumerable
<
EpMerge
>
mergeCells
=
GetMergeCells
(
sheet
);
List
<
double
>
colWidths
=
GetColWidths
(
sheet
);
IEnumerable
<
EpMerge
>
mergeCells
=
GetMergeCells
(
sheet
);
List
<
double
>
colWidths
=
GetColWidths
(
sheet
);
#
region
data
#
region
data
List
<
Dictionary
<
string
,
object
>>
datas
=
new
List
<
Dictionary
<
string
,
object
>>();
List
<
EpCellClass
>
cells
=
new
List
<
EpCellClass
>();
List
<
EpColumn
>
renders
=
new
List
<
EpColumn
>();
List
<
Dictionary
<
string
,
object
>>
datas
=
new
List
<
Dictionary
<
string
,
object
>>();
List
<
EpCellClass
>
cells
=
new
List
<
EpCellClass
>();
List
<
EpColumn
>
renders
=
new
List
<
EpColumn
>();
for
(
int
row
=
1
,
n
=
sheet
.
Dimension
.
End
.
Row
;
row
<=
n
;
row
++)
{
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>();
for
(
int
row
=
1
,
n
=
sheet
.
Dimension
.
End
.
Row
;
row
<=
n
;
row
++)
for
(
int
col
=
1
,
k
=
sheet
.
Dimension
.
End
.
Column
;
col
<=
k
;
col
++)
{
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>();
var
cell
=
sheet
.
Cells
[
row
,
col
];
if
(
cell
==
null
)
continue
;
for
(
int
col
=
1
,
k
=
sheet
.
Dimension
.
End
.
Column
;
col
<=
k
;
col
++)
{
var
cell
=
sheet
.
Cells
[
row
,
col
];
if
(
cell
==
null
)
continue
;
var
value
=
GetCellValue
(
cell
);
var
colName
=
Regex
.
Replace
(
cell
.
Address
,
"[0-9]"
,
""
,
RegexOptions
.
IgnoreCase
);
data
.
Add
(
colName
,
value
);
var
cellStyle
=
GetCellClass
(
cell
,
row
,
col
);
if
(
cellStyle
!=
null
)
cells
.
Add
(
cellStyle
);
var
render
=
GetCellRender
(
cell
,
row
,
col
);
if
(
render
!=
null
)
renders
.
Add
(
render
);
}
datas
.
Add
(
data
);
}
#
endregion
var
value
=
GetCellValue
(
cell
);
var
colName
=
Regex
.
Replace
(
cell
.
Address
,
"[0-9]"
,
""
,
RegexOptions
.
IgnoreCase
);
data
.
Add
(
colName
,
value
);
SheetType
sheetType
=
_sheetService
.
GetSheetType
(
sheet
.
Name
);
var
handler
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
var
cellStyle
=
GetCellClass
(
cell
,
row
,
col
);
if
(
cellStyle
!=
null
)
cells
.
Add
(
cellStyle
);
EpSheet
epSheet
=
new
EpSheet
()
{
fixedColumnsLeft
=
handler
?.
Point
.
DataFirstCellNum
??
0
,
fixedRowsTop
=
handler
?.
Point
.
DataFirstRowNum
??
0
,
cell
=
cells
,
colWidths
=
colWidths
,
data
=
datas
,
renders
=
renders
,
mergeCells
=
mergeCells
,
};
_cache
.
Set
(
key
,
epSheet
,
absoluteExpirationRelativeToNow
);
return
epSheet
;
var
render
=
GetCellRender
(
cell
,
row
,
col
);
if
(
render
!=
null
)
renders
.
Add
(
render
);
}
datas
.
Add
(
data
);
}
#
endregion
SheetType
sheetType
=
_sheetService
.
GetSheetType
(
sheet
.
Name
);
var
handler
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
);
EpSheet
epSheet
=
new
EpSheet
()
{
fixedColumnsLeft
=
handler
?.
Point
.
DataFirstCellNum
??
0
,
fixedRowsTop
=
handler
?.
Point
.
DataFirstRowNum
??
0
,
cell
=
cells
,
colWidths
=
colWidths
,
data
=
datas
,
renders
=
renders
,
mergeCells
=
mergeCells
,
};
_cache
.
Set
(
key
,
epSheet
,
absoluteExpirationRelativeToNow
);
return
epSheet
;
}
return
null
;
}
#
region
...
...
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