1. 程式人生 > >c# asp.net設定單元格格式

c# asp.net設定單元格格式

設定單元格格式如下:

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%