我導出數據的表,CSV格式,如:ASP.NET CSV Excel中的問題與奇怪的字符
"COL1","COL2","COL3"
"1","some text", "£232.00"
"2","some more text", "£111.00"
"3","other text", "£2.00"
出口的代碼是相當簡單的使用ashx的處理程序:
context.Response.Clear()
context.Response.ContentType = "text/csv"
context.Response.AddHeader("Content-disposition", "attachment;filename=data.csv")
context.Response.AddHeader("Cache-Control", "must-revalidate")
context.Response.AddHeader("Pragma", "must-revalidate")
context.Response.Write(data)
context.Response.Flush()
context.Response.End()
我的問題是當Excel試圖打開導出的文件時,字符Â
出現在所有£
符號之前,例如£232.00
當值應該是£232.00
。
這看起來像一個Unicode到UTF-8的翻譯錯誤。不過,我不知道如何修復它。 – 2010-03-15 18:55:55