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
4d573014
Commit
4d573014
authored
Feb 15, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
再次调整
parent
13d40beb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
19 deletions
+58
-19
performance/Performance.Services/OnlineExcel/Model/EpCellClass.cs
+8
-1
performance/Performance.Services/OnlineExcel/Model/EpSheet.cs
+4
-1
performance/Performance.Services/OnlineExcel/OnlineExcelService.Read.cs
+46
-17
No files found.
performance/Performance.Services/OnlineExcel/Model/EpCellClass.cs
View file @
4d573014
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
namespace
Performance.Services.OnlineExcel
namespace
Performance.Services.OnlineExcel
{
{
public
class
EpColumn
{
public
int
row
{
get
;
set
;
}
public
int
col
{
get
;
set
;
}
public
string
renderer
{
get
;
set
;
}
}
/// <summary>
/// <summary>
/// 单元格Class
/// 单元格Class
/// </summary>
/// </summary>
...
@@ -10,7 +16,8 @@ public class EpCellClass
...
@@ -10,7 +16,8 @@ public class EpCellClass
private
List
<
string
>
_className
;
private
List
<
string
>
_className
;
public
int
row
{
get
;
set
;
}
public
int
row
{
get
;
set
;
}
public
int
col
{
get
;
set
;
}
public
int
col
{
get
;
set
;
}
public
string
renderer
;
public
bool
editor
{
get
;
set
;
}
public
string
className
public
string
className
{
{
get
get
...
...
performance/Performance.Services/OnlineExcel/Model/EpSheet.cs
View file @
4d573014
namespace
Performance.Services.OnlineExcel
using
System.Collections.Generic
;
namespace
Performance.Services.OnlineExcel
{
{
/// <summary>
/// <summary>
/// 加载Excel汇总信息
/// 加载Excel汇总信息
/// </summary>
/// </summary>
public
class
EpSheet
public
class
EpSheet
{
{
public
object
renders
{
get
;
set
;
}
public
object
mergeCells
{
get
;
set
;
}
public
object
mergeCells
{
get
;
set
;
}
public
object
data
{
get
;
set
;
}
public
object
data
{
get
;
set
;
}
public
object
cell
{
get
;
set
;
}
public
object
cell
{
get
;
set
;
}
...
...
performance/Performance.Services/OnlineExcel/OnlineExcelService.Read.cs
View file @
4d573014
...
@@ -81,6 +81,9 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
...
@@ -81,6 +81,9 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
}
}
}
}
}
}
sheetNames
=
sheetNames
.
OrderBy
(
w
=>
w
.
SheetType
==
SheetType
.
Unidentifiable
?
1
:
0
).
ToList
();
_cache
.
Set
(
key
,
sheetNames
,
absoluteExpirationRelativeToNow
);
_cache
.
Set
(
key
,
sheetNames
,
absoluteExpirationRelativeToNow
);
return
sheetNames
;
return
sheetNames
;
...
@@ -113,6 +116,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
...
@@ -113,6 +116,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
List
<
Dictionary
<
string
,
object
>>
datas
=
new
List
<
Dictionary
<
string
,
object
>>();
List
<
Dictionary
<
string
,
object
>>
datas
=
new
List
<
Dictionary
<
string
,
object
>>();
List
<
EpCellClass
>
cells
=
new
List
<
EpCellClass
>();
List
<
EpCellClass
>
cells
=
new
List
<
EpCellClass
>();
List
<
EpColumn
>
renders
=
new
List
<
EpColumn
>();
for
(
int
row
=
1
,
n
=
sheet
.
Dimension
.
End
.
Row
;
row
<=
n
;
row
++)
for
(
int
row
=
1
,
n
=
sheet
.
Dimension
.
End
.
Row
;
row
<=
n
;
row
++)
{
{
...
@@ -130,6 +134,10 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
...
@@ -130,6 +134,10 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
var
cellStyle
=
GetCellClass
(
cell
,
row
,
col
);
var
cellStyle
=
GetCellClass
(
cell
,
row
,
col
);
if
(
cellStyle
!=
null
)
if
(
cellStyle
!=
null
)
cells
.
Add
(
cellStyle
);
cells
.
Add
(
cellStyle
);
var
render
=
GetCellRender
(
cell
,
row
,
col
);
if
(
render
!=
null
)
renders
.
Add
(
render
);
}
}
datas
.
Add
(
data
);
datas
.
Add
(
data
);
}
}
...
@@ -140,6 +148,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
...
@@ -140,6 +148,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
cell
=
cells
,
cell
=
cells
,
colWidths
=
colWidths
,
colWidths
=
colWidths
,
data
=
datas
,
data
=
datas
,
renders
=
renders
,
mergeCells
=
mergeCells
,
mergeCells
=
mergeCells
,
};
};
_cache
.
Set
(
key
,
epSheet
,
absoluteExpirationRelativeToNow
);
_cache
.
Set
(
key
,
epSheet
,
absoluteExpirationRelativeToNow
);
...
@@ -201,47 +210,66 @@ private static List<double> GetColWidths(ExcelWorksheet sheet)
...
@@ -201,47 +210,66 @@ private static List<double> GetColWidths(ExcelWorksheet sheet)
return
colWidths
;
return
colWidths
;
}
}
/// <summary>
/// <summary>
/// 读取
类Class
/// 读取
单元格渲染方式
/// </summary>
/// </summary>
/// <param name="cell"></param>
/// <param name="cell"></param>
/// <param name="row"></param>
/// <param name="row"></param>
/// <param name="col"></param>
/// <param name="col"></param>
/// <returns></returns>
/// <returns></returns>
private
EpC
ellClass
GetCellClass
(
ExcelRange
cell
,
int
row
,
int
col
)
private
EpC
olumn
GetCellRender
(
ExcelRange
cell
,
int
row
,
int
col
)
{
{
var
c
ellStyle
=
new
EpCellClass
var
c
olumn
=
new
EpColumn
{
{
row
=
row
-
1
,
row
=
row
-
1
,
col
=
col
-
1
col
=
col
-
1
,
};
};
if
(
cell
.
Value
is
ExcelErrorValue
)
if
(
cell
.
Value
is
ExcelErrorValue
)
{
{
c
ellStyle
.
renderer
=
"customExcelErrorValueStylesRenderer"
;
c
olumn
.
renderer
=
"customExcelErrorValueStylesRenderer"
;
}
}
else
if
(!
string
.
IsNullOrEmpty
(
cell
.
Formula
))
else
if
(!
string
.
IsNullOrEmpty
(
cell
.
Formula
))
{
{
c
ellStyle
.
renderer
=
"customFormulaStylesRenderer"
;
c
olumn
.
renderer
=
"customFormulaStylesRenderer"
;
}
}
else
if
(
cell
.
Style
.
Border
.
Top
.
Style
!=
ExcelBorderStyle
.
None
else
if
(
cell
.
Style
.
Border
.
Top
.
Style
!=
ExcelBorderStyle
.
None
||
cell
.
Style
.
Border
.
Bottom
.
Style
!=
ExcelBorderStyle
.
None
||
cell
.
Style
.
Border
.
Bottom
.
Style
!=
ExcelBorderStyle
.
None
||
cell
.
Style
.
Border
.
Left
.
Style
!=
ExcelBorderStyle
.
None
||
cell
.
Style
.
Border
.
Left
.
Style
!=
ExcelBorderStyle
.
None
||
cell
.
Style
.
Border
.
Right
.
Style
!=
ExcelBorderStyle
.
None
)
||
cell
.
Style
.
Border
.
Right
.
Style
!=
ExcelBorderStyle
.
None
)
{
{
c
ellStyle
.
renderer
=
"customExcelBorderStylesRenderer"
;
c
olumn
.
renderer
=
"customExcelBorderStylesRenderer"
;
}
}
if
(
string
.
IsNullOrEmpty
(
column
.
renderer
))
return
null
;
if
(
HorizontalMapps
.
ContainsKey
(
cell
.
Style
.
HorizontalAlignment
.
ToString
()))
return
column
;
{
cellStyle
.
AddClassName
(
HorizontalMapps
[
cell
.
Style
.
HorizontalAlignment
.
ToString
()]);
}
}
if
(
VerticalMapps
.
ContainsKey
(
cell
.
Style
.
VerticalAlignment
.
ToString
()))
/// <summary>
/// 读取类Class
/// </summary>
/// <param name="cell"></param>
/// <param name="row"></param>
/// <param name="col"></param>
/// <returns></returns>
private
EpCellClass
GetCellClass
(
ExcelRange
cell
,
int
row
,
int
col
)
{
{
cellStyle
.
AddClassName
(
VerticalMapps
[
cell
.
Style
.
VerticalAlignment
.
ToString
()]);
var
cellStyle
=
new
EpCellClass
}
{
if
(
string
.
IsNullOrEmpty
(
cellStyle
.
renderer
)
&&
string
.
IsNullOrEmpty
(
cellStyle
.
className
))
row
=
row
-
1
,
return
null
;
col
=
col
-
1
,
editor
=
false
};
//if (HorizontalMapps.ContainsKey(cell.Style.HorizontalAlignment.ToString()))
//{
// cellStyle.AddClassName(HorizontalMapps[cell.Style.HorizontalAlignment.ToString()]);
//}
//if (VerticalMapps.ContainsKey(cell.Style.VerticalAlignment.ToString()))
//{
// cellStyle.AddClassName(VerticalMapps[cell.Style.VerticalAlignment.ToString()]);
//}
cellStyle
.
AddClassName
(
"htCenter"
);
cellStyle
.
AddClassName
(
"htMiddle"
);
return
cellStyle
;
return
cellStyle
;
}
}
/// <summary>
/// <summary>
...
@@ -251,7 +279,8 @@ private EpCellClass GetCellClass(ExcelRange cell, int row, int col)
...
@@ -251,7 +279,8 @@ private EpCellClass GetCellClass(ExcelRange cell, int row, int col)
/// <returns></returns>
/// <returns></returns>
private
object
GetCellValue
(
ExcelRange
cell
)
private
object
GetCellValue
(
ExcelRange
cell
)
{
{
return
(
cell
.
Value
is
ExcelErrorValue
||
!
string
.
IsNullOrEmpty
(
cell
.
Formula
))
?
cell
.
Text
:
cell
.
Value
;
//return (cell.Value is ExcelErrorValue || !string.IsNullOrEmpty(cell.Formula)) ? cell.Text : cell.Value;
return
cell
.
Text
;
}
}
/// <summary>
/// <summary>
...
...
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