Microsoft Excel mangles Diacritics in .csv files?

后端 未结 22 1701
粉色の甜心
粉色の甜心 2020-11-22 05:02

I am programmatically exporting data (using PHP 5.2) into a .csv test file.
Example data: Numéro 1 (note the accented e). The data is utf-8 (

22条回答
  •  北海茫月
    2020-11-22 05:22

    If you have legacy code in vb.net like I have, the following code worked for me:

        Response.Clear()
        Response.ClearHeaders()
        Response.ContentType = "text/csv"
        Response.Expires = 0
        Response.AddHeader("Content-Disposition", "attachment; filename=export.csv;")
        Using sw As StreamWriter = New StreamWriter(Context.Response.OutputStream, System.Text.Encoding.Unicode)
            sw.Write(csv)
            sw.Close()
        End Using
        Response.End()
    

提交回复
热议问题