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
2197f5ed
Commit
2197f5ed
authored
Jun 05, 2023
by
ruyun.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载样式调整
parent
3a055eff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
23 deletions
+26
-23
performance/Performance.Services/ComputeService.UniteDeptDetail.cs
+26
-23
No files found.
performance/Performance.Services/ComputeService.UniteDeptDetail.cs
View file @
2197f5ed
...
...
@@ -425,23 +425,23 @@ private string ValueFormating(decimal? value, string format)
{
if
(
format
==
UniteDept
.
Format
.
整数百分比
.
ToString
())
{
return
string
.
Format
(
"{0:
P0
}"
,
total
);
return
string
.
Format
(
"{0:
0%
}"
,
total
);
}
else
if
(
format
==
UniteDept
.
Format
.
一位小数百分比
.
ToString
())
{
return
string
.
Format
(
"{0:
P1
}"
,
total
);
return
string
.
Format
(
"{0:
0.#%
}"
,
total
);
}
else
if
(
format
==
UniteDept
.
Format
.
两位小数百分比
.
ToString
())
{
return
string
.
Format
(
"{0:
P2
}"
,
total
);
return
string
.
Format
(
"{0:
0.##%
}"
,
total
);
}
else
if
(
format
==
UniteDept
.
Format
.
三位小数百分比
.
ToString
())
{
return
string
.
Format
(
"{0:
P3
}"
,
total
);
return
string
.
Format
(
"{0:
0.###%
}"
,
total
);
}
else
if
(
format
==
UniteDept
.
Format
.
四位小数百分比
.
ToString
())
{
return
string
.
Format
(
"{0:
P4
}"
,
total
);
return
string
.
Format
(
"{0:
0.####%
}"
,
total
);
}
else
if
(
Math
.
Abs
(
total
)
<
1.5
m
)
{
...
...
@@ -618,13 +618,14 @@ public string ExcelDownload(UniteDeptDetailResponse uniteDeptDetail, string name
using
(
FileStream
fs
=
new
FileStream
(
filepath
,
FileMode
.
OpenOrCreate
))
using
(
ExcelPackage
package
=
new
ExcelPackage
(
fs
))
{
var
worksheet
=
package
.
Workbook
.
Worksheets
.
Add
(
name
);
var
worksheet
=
package
.
Workbook
.
Worksheets
.
Add
(
uniteDeptDetail
.
Title
);
worksheet
.
View
.
ShowGridLines
=
false
;
var
maxColIndex
=
GetMaxColumnIndex
(
0
,
uniteDeptDetail
.
DetailItems
);
worksheet
.
SetValue
(
1
,
1
,
uniteDeptDetail
.
Title
);
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Merge
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Style
.
Font
.
Size
=
20
;
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Style
.
Font
.
Size
=
18
;
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
1
,
1
,
1
,
maxColIndex
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
...
...
@@ -646,9 +647,13 @@ int WriteSheetCells(ExcelWorksheet worksheet, int maxColIndex, int rowIndex, Lis
{
++
rowIndex
;
worksheet
.
SetValue
(
rowIndex
,
1
,
$"
{
item
.
Title
}
:
{
item
.
TotalFormat
}
"
);
if
(!
string
.
IsNullOrEmpty
(
item
.
Remark
))
{
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
AddComment
(
item
.
Remark
,
"System"
);
}
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Merge
=
true
;
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Size
=
1
8
;
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Size
=
1
4
;
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Left
;
...
...
@@ -667,7 +672,7 @@ int WriteSheetCells(ExcelWorksheet worksheet, int maxColIndex, int rowIndex, Lis
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
headers
.
ElementAt
(
colIndex
));
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Font
.
Size
=
1
6
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Font
.
Size
=
1
1
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
...
...
@@ -678,7 +683,7 @@ int WriteSheetCells(ExcelWorksheet worksheet, int maxColIndex, int rowIndex, Lis
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Merge
=
true
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Bold
=
true
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Size
=
1
6
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Size
=
1
1
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
...
...
@@ -691,32 +696,30 @@ int WriteSheetCells(ExcelWorksheet worksheet, int maxColIndex, int rowIndex, Lis
rowIndex
=
rowIndex
+
1
;
for
(
int
colIndex
=
0
;
colIndex
<
headers
.
Count
();
colIndex
++)
{
object
cellValue
=
row
[
headers
.
ElementAt
(
colIndex
)];
// 获取单元格的值
double
numericValue
;
// 用于存储转换后的数值
if
(
cellValue
!=
null
&&
double
.
TryParse
(
cellValue
.
ToString
(),
out
numericValue
))
{
if
(
numericValue
<
0
)
var
cellValue
=
row
[
headers
.
ElementAt
(
colIndex
)]?.
ToString
()
??
""
;
// 获取单元格的值
double
numericValue
=
0
;
if
(
cellValue
.
EndsWith
(
"%"
)
&&
double
.
TryParse
(
cellValue
.
Replace
(
"%"
,
""
),
out
numericValue
))
{
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Fill
.
PatternType
=
ExcelFillStyle
.
Solid
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Fill
.
BackgroundColor
.
SetColor
(
Color
.
Red
)
;
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
numericValue
/
100
)
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Numberformat
.
Format
=
"0.00%"
;
}
else
if
(
double
.
TryParse
(
cellValue
,
out
numericValue
))
{
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
numericValue
);
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Numberformat
.
Format
=
"0.00"
;
}
else
{
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
row
[
headers
.
ElementAt
(
colIndex
)]);
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
Fill
.
PatternType
=
ExcelFillStyle
.
Solid
;
worksheet
.
Cells
[
rowIndex
,
1
,
rowIndex
,
maxColIndex
].
Style
.
Fill
.
BackgroundColor
.
SetColor
(
Color
.
GhostWhite
);
worksheet
.
SetValue
(
rowIndex
,
colIndex
+
1
,
cellValue
);
}
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Font
.
Size
=
1
6
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Font
.
Size
=
1
1
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
if
(
colIndex
+
1
==
headers
.
Count
())
{
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Merge
=
true
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Size
=
1
6
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Font
.
Size
=
1
1
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
Border
.
BorderAround
(
ExcelBorderStyle
.
Thin
);
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
VerticalAlignment
=
ExcelVerticalAlignment
.
Center
;
worksheet
.
Cells
[
rowIndex
,
colIndex
+
1
,
rowIndex
,
maxColIndex
].
Style
.
HorizontalAlignment
=
ExcelHorizontalAlignment
.
Center
;
...
...
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