- 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:@");
- }
- }
Web页面的数据导出excel时的格式问题
最新推荐文章于 2018-06-11 09:11:33 发布
本文介绍如何在Web页面中使用GridView导出数据到Excel时,针对不同类型的数据显示正确的格式,包括文本、日期、数字、货币及百分比等,并提供了一个具体的代码示例。
1373

被折叠的 条评论
为什么被折叠?



