c# asp.net设置单元格格式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cherish_CX/article/details/52824573

设置单元格格式如下:

dg.Items[i].Cells[sfzh].Attributes.Add("style", "vnd.ms-excel.numberformat:@");

//dg是一个datatable,i表示第几行,sfzh是需要转换格式的列名

//把vnd.ms-excel.numberformat:@改成相应的格式,就可以设置单元格格式


//文本:vnd.ms-excel.numberformat:@

//日期:vnd.ms-excel.numberformat:yyyy/mm/dd
//数字:vnd.ms-excel.numberformat:#,##0.00
//货币:vnd.ms-excel.numberformat:¥#,##0.00
//百分比:vnd.ms-excel.numberformat:#0.00%






猜你喜欢

转载自blog.csdn.net/cherish_CX/article/details/52824573