我现在用DataGrid绑定了一些数据,类似这样的2/8,25/30 
但是导出到Execl后有些数据就变样了,比如“2/8”就会变成“2月8日”,如果数据量大的话就没有这个问题,这是怎么回事?

解决方案 »

  1.   

    这要看楼主用的是什么方法导出Excel???
      

  2.   

    类似问题:请问怎样把DataGrid的数据导出到excel中呢?
    谢谢
      

  3.   

    这个好象是execl的格式问题,它会自做聪明得帮你转一些格式。
      

  4.   

    我是用这种方法导出到Excel的:        HttpContext.Current.Response.Charset = "GB2312" '"UTF-8"
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8")
            Response.ContentType = "application/ms-excel" '"application/vnd.ms-excel"
            Response.AppendHeader("Content-Disposition", "attachment;filename=Promotion.xls")
            Response.Charset = ""
            EnableViewState = False
            Dim tw As System.IO.StringWriter = New System.IO.StringWriter
            Dim hw As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(tw)
            hw.WriteLine("<b><u><font size='5'>" & Viewstate("RPname") & "</font></u></b>")
            hw.WriteLine("<br>")
            MyDG.HeaderStyle.Font.Bold = True
            MyDG.RenderControl(hw)
            Response.Write(tw.ToString)
            Response.End()