Web页面的数据导出excel时的格式问题

来源:互联网 发布:淘宝网 pong ipad 编辑:程序博客网 时间:2024/05/21 06:36
  1. Web页面的数据导出excel时的格式问题  
  2. 文本:vnd.ms-excel.numberformat:@
  3. 日期:vnd.ms-excel.numberformat:yyyy/mm/dd
  4. 数字:vnd.ms-excel.numberformat:#,##0.00
  5. 货币:vnd.ms-excel.numberformat:¥#,##0.00
  6. 百分比:vnd.ms-excel.numberformat: #0.00%
  7. 在GridView中执行RowDataBound事件
  8.     protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
  9.     {
  10.         if (e.Row.RowType == DataControlRowType.DataRow)
  11.         {
  12.             e.Row.Cells[4].Attributes.Add("style""vnd.ms-excel.numberformat:@");
  13.             e.Row.Cells[5].Attributes.Add("style""vnd.ms-excel.numberformat:@");
  14.             e.Row.Cells[6].Attributes.Add("style""vnd.ms-excel.numberformat:@");
  15.             e.Row.Cells[7].Attributes.Add("style""vnd.ms-excel.numberformat:@");
  16.             e.Row.Cells[8].Attributes.Add("style""vnd.ms-excel.numberformat:@");
  17.         }
  18.     }
原创粉丝点击