ASP.NET csv excel issue with strange characters

Posted by cfdev9 on Stack Overflow See other posts from Stack Overflow or by cfdev9
Published on 2010-03-15T18:46:10Z Indexed on 2010/03/15 18:49 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

I'm exporting a table of data to csv format, eg

    "COL1","COL2","COL3"
    "1","some text", "£232.00"
    "2","some more text", "£111.00"
    "3","other text", "£2.00"

The code to export is fairly simple using an ashx handler

    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()

My issue is when excel trys to open the exported file the character  appears before all £ signs, eg £232.00 when the value should be £232.00

© Stack Overflow or respective owner

Related posts about export-to-excel

Related posts about csv