A、单元格格式设置,默认为常规类型;Excel
代码:
Excel.Range r = mySheet.get_Range(mySheet.Cells[1, 1],
mySheet.Cells[DT.Rows.Count + 2, DT.Columns.Count - 3]);
&&&&&& &&&&&&&//设置单元格格式为文本类型,文本类型可设置上下标
r.NumberFormat = "@";
//设置单元格格式为数值类型,小数点后 2 位
r.NumberForma = "0.00_ "
//设置单元格格式为货币类型,小数点后 2 位
r.NumberForma = "¥#,##0.00;¥-#,##0.00"
//设置单元格格式为会计专用类型,小数点后 2 位
r.NumberForma = _"_ ¥* #,##0.00_ ;_ ¥* -#,##0.00_ ;_ ¥* ""-""??
_ ;_ @_ "
//设置单元格格式为日期类型
r.NumberForma = "yyyy-m-d"
//设置单元格格式为时间类型
r.NumberForma = "[$-F400]h:mm:ss AM/PM"
//设置单元格格式为百分比类型,小数点后 2 位
&r.NumberForma = "0.00%"
//设置单元格格式为分数类型,分母为一位数
&r.NumberForma = "# ?/?"
//设置单元格格式为科学技术类型,小数位数为 2
&r.NumberForma = "0.00E+00"
//设置单元格格式为特殊类型
&&& &r.NumberForma = "000000"
B、上下标格式的控制;
代码:
- 1
- 2
- 3
前往页