我有gridview,我正在用下面的代码导出到excel那个gridview。
Response.ClearContent()
Response.AddHeader("content-disposition", "attachment;
filename=ExcelShipments_" & DateTime.Now.Ticks & ".xls")
Response.ContentType = "application/excel"
Dim sWriter As New StringWriter()
Dim hTextWriter As New HtmlTextWriter(sWriter)
Dim hForm As New HtmlForm()
ucShipmentList.ShipmentGrid.Parent.Controls.Add(hForm)
hForm.Attributes("runat") = "server"
hForm.Controls.Add(ucShipmentList.ShipmentGrid)
hForm.RenderControl(hTextWriter)
Dim sBuilder As New StringBuilder()
sBuilder.Append("<html xmlns:v=""urn:schemas-microsoft-com:vml"" xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:x=""urn:schemas-microsoft-com:office:excel"" xmlns=""http://www.w3.org/TR/REC-html40""> <head><meta http-equiv=""Content-Type"" content=""text/html;charset=windows-1252""><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>ExportToExcel</x:Name><x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head> <body>")
sBuilder.Append(sWriter.ToString() & "</body></html>")
Response.Write(sBuilder.ToString())
Response.End()
我在页面默认设置中有荷兰语,因此页面上的网格显示是正确的,但是在导出到 excel 时,它显示以英语导出。
如何在导出到 Excel 时保留语言?