NPOI 擴展:NPOI.CSS
NPOI.CSS 是一個可以在使用 NPOI 時用類CSS的方法設置單元格樣式的NPOI擴展。
NPOI.CSS 用法
目前,本擴展只支持.NET4及以上版本的項目,低版本的暫時不支持,請見諒。
-
引用NPOI.CSS.dll
-
using NPOI.CSS;
-
cell.CSS("color:red;font-weight:bold;font-size:11;font-name:宋體;border-type:thin;")
設置字體 font-name
注意只能有一個值
字體下劃線 font-underline
-
none 無下劃線
-
single 單下劃線
-
double 雙下劃線
-
single_accounting 會計用單下劃線
-
double_accounting 會計用雙下劃線 ## 字標 font-superscript
-
none 無
-
sub 下標
-
super 上標
橫向對齊方式 text-align
-
general
-
left
-
center
-
right
-
fill
-
justify
-
center_selection
-
distributed
縱向對齊方式 vertical-align
-
top
-
center
-
bottom
-
justify
-
distributed
邊框樣式 border-type
-
none
-
thin
-
medium
-
dashed
-
hair
-
thick
-
double
-
dotted
-
medium_dashed
-
dash_dot
-
medium_dash_dot
-
dash_dot_dot
-
medium_dash_dot_dot
-
slanted_dash_dot
斜體 font-italic
-
true
-
false
刪除線 font-strikeout
-
true
-
false
數據格式 data-format
參考NPOI官方文檔中格式化字符串的設定要求
字體顏色 color / 背景色 background-color
-
black
-
white
-
red
-
bright_green
-
blue
-
yellow
-
pink
-
turquoise
-
dark_red
-
green
-
dark_blue
-
dark_yellow
-
violet
-
teal
-
grey_25_percent
-
grey_50_percent
-
cornflower_blue
-
maroon
-
lemon_chiffon
-
orchid
-
coral
-
royal_blue
-
light_cornflower_blue
-
sky_blue
-
light_turquoise
-
light_green
-
light_yellow
-
pale_blue
-
rose
-
lavender
-
tan
-
light_blue
-
aqua
-
lime
-
gold
-
light_orange
-
orange
-
blue_grey
-
grey_40_percent
-
dark_teal
-
sea_green
-
dark_green
-
olive_green
-
brown
-
plum
-
indigo
-
grey_80_percent
-
automatic
為了提升輸入效率,cssKey支持縮寫別名:
-
font-color
color
fc -
font-weight
fw -
font-name
fn -
font-size
fs -
font-italic
italic
i -
font-underline
underline
u -
font-strikeout
deleteline
d-line
strikeout
d -
font-superscript
font-offset
superscript
fss
ss -
background-color
bg-color
bg-c
bgc -
text-align
align -
vertical-align
v-align -
data-format
format