0
我有gridview,我出口到excel的gridview與下面的代碼。導出到excel與瀏覽器本地化 - ASP.Net
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時保留語言?
任何人都可以提供這方面的意見嗎? – 2013-02-18 12:11:23
你可以嘗試改變charset = windows-1252到charset = utf-8,看看是否改變了什麼? – bUKaneer 2013-02-18 12:15:11
我試着改變它,但仍然不能正常工作。 – 2013-02-18 12:33:59