views:

271

answers:

1

I'm exporting a table of data to CSV format, e.g.:

    "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 tries to open the exported file the character  appears before all £ signs, e.g. £232.00 when the value should be £232.00.

+1  A: 

Without looking up documentation, I believe you need to set the encoding in a header or there may even be a more specific property of Response to set.

Mark Hurd
thanks for the tips this solved it "context.Response.ContentEncoding = System.Text.Encoding.Unicode"
cfdev9