【发布时间】:2010-03-15 18:46:10
【问题描述】:
我正在将数据表导出为 CSV 格式,例如:
"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 的转换错误。不过,我不知道如何解决它。
标签: c# vb.net csv export-to-excel