''''给要处理列加样式;解决收据号导出是‘0’自动处理的问题
e.Item.Cells(0).Attributes.Add("style","vnd.ms-excel.numberformat:@")
End Sub
导出方法
Public Overloads Shared Sub OutToExcel1(ByVal dg As DataGrid,ByVal httpResponse As HttpResponse,ByVal httpPage As Page,ByVal fileName As String) httpResponse.Clear() httpResponse.Buffer = True httpResponse.Charset = "GB2312" httpResponse.AppendHeader("Content-Disposition","attachment;filename=" & fileName) httpResponse.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312") '设置输出流为简体中文 httpResponse.ContentType = "application/ms-excel" '设置输出文件类型为excel文件。 httpPage.EnableViewState = False Dim myCItrad As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("ZH-CN",True) Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter(myCItrad) Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter) dg.RenderControl(oHtmlTextWriter) httpResponse.Write(oStringWriter.ToString()) httpResponse.End() End Sub