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
c026d920
Commit
c026d920
authored
Aug 08, 2019
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
样式
parent
5ac214da
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
performance/Performance.Services/CellStyle.cs
+91
-0
No files found.
performance/Performance.Services/CellStyle.cs
0 → 100644
View file @
c026d920
using
NPOI.HSSF.UserModel
;
using
NPOI.HSSF.Util
;
using
NPOI.SS.UserModel
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.Services
{
public
enum
StyleType
{
//列头固定,
列头
,
系数
,
默认
,
}
public
enum
CellFormat
{
数字
,
数字
2
,
百分比
,
百分比
2
,
时间
,
默认
,
}
public
class
CellStyle
{
public
static
ICellStyle
CreateCellStyle
(
IWorkbook
wb
,
StyleType
type
=
StyleType
.
默认
,
CellFormat
format
=
CellFormat
.
默认
)
{
ICellStyle
cellStyle
=
wb
.
CreateCellStyle
();
//字体
IFont
font
=
wb
.
CreateFont
();
font
.
FontHeightInPoints
=
11
;
font
.
FontName
=
"微软雅黑"
;
font
.
Color
=
HSSFColor
.
Black
.
Index
;
//边框
cellStyle
.
BorderBottom
=
BorderStyle
.
Thin
;
cellStyle
.
BorderLeft
=
BorderStyle
.
Thin
;
cellStyle
.
BorderRight
=
BorderStyle
.
Thin
;
cellStyle
.
BorderTop
=
BorderStyle
.
Thin
;
//边框颜色
cellStyle
.
BottomBorderColor
=
HSSFColor
.
Black
.
Index
;
cellStyle
.
TopBorderColor
=
HSSFColor
.
Black
.
Index
;
cellStyle
.
LeftBorderColor
=
HSSFColor
.
Black
.
Index
;
cellStyle
.
RightBorderColor
=
HSSFColor
.
Black
.
Index
;
cellStyle
.
SetFont
(
font
);
switch
(
type
)
{
case
StyleType
.
列头
:
cellStyle
.
FillForegroundColor
=
HSSFColor
.
Orange
.
Index
;
break
;
case
StyleType
.
系数
:
cellStyle
.
FillForegroundColor
=
HSSFColor
.
Green
.
Index
;
break
;
case
StyleType
.
默认
:
cellStyle
.
SetFont
(
font
);
break
;
}
IDataFormat
datastyle
=
wb
.
CreateDataFormat
();
switch
(
format
)
{
case
CellFormat
.
时间
:
cellStyle
.
DataFormat
=
datastyle
.
GetFormat
(
"yyyy/mm/dd"
);
break
;
case
CellFormat
.
数字
:
cellStyle
.
DataFormat
=
datastyle
.
GetFormat
(
"0"
);
break
;
case
CellFormat
.
数字
2
:
cellStyle
.
DataFormat
=
datastyle
.
GetFormat
(
"0.00"
);
break
;
case
CellFormat
.
百分比
:
cellStyle
.
DataFormat
=
datastyle
.
GetFormat
(
"0%"
);
break
;
case
CellFormat
.
百分比
2
:
cellStyle
.
DataFormat
=
datastyle
.
GetFormat
(
"0.00%"
);
break
;
case
CellFormat
.
默认
:
cellStyle
.
SetFont
(
font
);
break
;
}
return
cellStyle
;
}
}
}
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