# 格式属性 ## 单元格属性表
属性值 全称
说明
值示例 Aspose方法或者属性
ct celltype 单元格值格式:文本、时间等 单元格格式
bg background 背景颜色 #fff000 setBackgroundColor
ff fontfamily 字体 0 微软雅黑、1 宋体(Song)、2 黑体(ST Heiti)、3 楷体(ST Kaiti)、 4仿宋(ST FangSong)、 5 新宋体(ST Song)、 6 华文新魏、 7华文行楷、 8 华文隶书、 9 Arial、 10 Times New Roman 、11 Tahoma 、12 Verdana Style.Font object's Name property.
fc fontcolor 字体颜色 #fff000 Style.Font object's Color property
bl bold 粗体 0 常规 、 1加粗 Style.Font object's IsBold property to true.
it italic 斜体 0 常规 、 1 斜体
fs fontsize 字体大小 14 Style.Font object's Size property.
cl cancelline 删除线 0 常规 、 1 删除线 Style.Font object's Underline property
ul underline 下划线 0 常规 、 1 下划线
bs borderstyle 边框样式 0 none LineStyle
1 Thin
2 Hair
3 Dotted
4 Dashed
5 DashDot
6 DashDotDot
7 Double
8 Medium
9 MediumDashed
10 MediumDashDot
11 MediumDashDotDot
12 SlantedDashDot
13 Thick
bc bordercolor 边框颜色 #fff000 setBorderColor
bs_t borderstyleTop 上边框样式 同上
bc_t bordercolorTop 上边框颜色
bs_b borderstyleBottom 下边框样式
bc_b bordercolorBottom 下边框颜色
bs_l borderstyleLeft 左边框样式
bc_l bordercolorLeft 左边框颜色
bs_r borderstyleRight 右边框样式
bc_r bordercolorRight 右边框颜色
vt verticaltype 垂直对齐 0 中间、1 上、2下 setVerticalAlignment
ht horizontaltype 水平对齐 0 居中、1 左、2右 setHorizontalAlignment
mc mergecell 合并单元格 { rs: 10, cs:5 } 表示从此cell开始到10行5列的cell进行合并。 Merge
tr textrotate 文字旋转 0: 0、1: 45 、2:-45、3 竖排文字、4: 90 、5:-90 setRotationAngle
fl floatlenght 小数位数 3
tb textbeak 文本换行 0 截断、1溢出、2 自动换行 2:setTextWrapped
0和1:IsTextWrapped = true
ov originvalue 原始值
v value 显示值
f function 公式 setFormula
setArrayFormula
workbook.calculateFormula();
以下为3个单元格存储: ```json [ {r:0, c:1, v: { v:"显示", f:"=SUM(A2)", bg:"#fff000", bs:"1",bc:"#000"}}, {r:10, c:11, v:"值2"}, {r:10, c:11, v:{f:"=sum", v:"100"}} ] ``` ##
单元格格式
参考[Aspose.Cells](https://docs.aspose.com/display/cellsnet/List+of+Supported+Number+Formats#ListofSupportedNumberFormats-Aspose.Cells) 格式设置为: ```json { "v": "", "f": "", "ct": { "v": 1, "f": "#,##0.00", "t": " Decimal" } } ``` |参数|说明|使用| | ------------ | ------------ | ------------ | |v|value,Aspose中的快捷设置值|`var currencyStyle = book.CreateStyle();`
`currencyStyle.Number = 8;`| |f|Format:格式的定义串 `$#,##0;$-#,##0`|`var currencyStyle = book.CreateStyle();`
`currencyStyle.Custom  = "#,##0 SEK";`| |t|Type类型:
0:General
1:Decimal
2:Currency
3:Percentage
4:Scientific
5:Fraction
6:Date
7:Time
8:Accounting
9:Text
10:DateTime|类型是前端区分的格式,excel导入时根据导入format字符的关键字来区分是哪种类型:
1.含YYYY、MM、DD的是6| Aspose设置如下: | Value | Type | Format String | |-------|------------|---------------------------------------------| | 0 | General | General | | 1 | Decimal | 0 | | 2 | Decimal | 0\.00 | | 3 | Decimal | \#,\#\#0 | | 4 | Decimal | \#,\#\#0\.00 | | 5 | Currency | $\#,\#\#0;$\-\#,\#\#0 | | 6 | Currency | $\#,\#\#0;$\-\#,\#\#0 | | 7 | Currency | $\#,\#\#0\.00;$\-\#,\#\#0\.00 | | 8 | Currency | $\#,\#\#0\.00;$\-\#,\#\#0\.00 | | 9 | Percentage | 0% | | 10 | Percentage | 0\.00% | | 11 | Scientific | 0\.00E\+00 | | 12 | Fraction | \# ?/? | | 13 | Fraction | \# / | | 14 | Date | m/d/yy | | 15 | Date | d\-mmm\-yy | | 16 | Date | d\-mmm | | 17 | Date | mmm\-yy | | 18 | Time | h:mm AM/PM | | 19 | Time | h:mm:ss AM/PM | | 20 | Time | h:mm | | 21 | Time | h:mm:ss | | 22 | Time | m/d/yy h:mm | | 37 | Currency | \#,\#\#0;\-\#,\#\#0 | | 38 | Currency | \#,\#\#0;\-\#,\#\#0 | | 39 | Currency | \#,\#\#0\.00;\-\#,\#\#0\.00 | | 40 | Currency | \#,\#\#0\.00;\-\#,\#\#0\.00 | | 41 | Accounting | \_ \* \#,\#\#0\_ ;\_ \* "\_ ;\_ @\_ | | 42 | Accounting | \_ $\* \#,\#\#0\_ ;\_ $\* "\_ ;\_ @\_ | | 43 | Accounting | \_ \* \#,\#\#0\.00\_ ;\_ \* "??\_ ;\_ @\_ | | 44 | Accounting | \_ $\* \#,\#\#0\.00\_ ;\_ $\* "??\_ ;\_ @\_ | | 45 | Time | mm:ss | | 46 | Time | h :mm:ss | | 47 | Time | mm:ss\.0 | | 48 | Scientific | \#\#0\.0E\+00 | | 49 | Text | @ | 导入/导出只用考虑用户看到的数据样式,例如excel中处理日期格式的方式为把日期统一转换为数字:42736 代表 2017-1-1,