excel输出 转载
EXCEL输出类型:
1) 文本:vnd.ms-excel.numberformat:@
2) 日期:vnd.ms-excel.numberformat:yyyy/mm/dd
3) 数字:vnd.ms-excel.numberformat:#,##0.00
4) 货币:vnd.ms-excel.numberformat:¥#,##0.00 vd;k;
5) 百分比:vnd.ms-excel.numberformat: #0.00%
具体调用(在GridView的RowDataBound事件中写):
- C# code
-
View Code
1 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
2 {
3 if (e.Row.RowType == DataControlRowType.DataRow)
4 {
5 //你要绑定的数据类型的列
6 e.Row.Cells[1].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
7 // 你要绑定的日期类型的列
8 e.Row.Cells[2].Attributes.Add("style", "vnd.ms-excel.numberformat:yyyy/mm/dd hh:mm:ss");
9 // 以此类推...
10 }
11 }