Web页面的数据导出excel时的格式问题
来源:互联网 发布:淘宝网 pong ipad 编辑:程序博客网 时间:2024/05/21 06:36
- Web页面的数据导出excel时的格式问题
- 文本: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%
- 在GridView中执行RowDataBound事件
- protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Cells[4].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
- e.Row.Cells[5].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
- e.Row.Cells[6].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
- e.Row.Cells[7].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
- e.Row.Cells[8].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
- }
- }