What to set as mimetype for CSV files to open in spreadsheet applications

前端 未结 1 1851
野性不改
野性不改 2020-12-05 16:53

My application lets users download their data as CSV files. These are supposed to open in spreadsheet applications. On a Linux system, I get prompted correctly to open with

相关标签:
1条回答
  • 2020-12-05 17:44

    Try this:

    Content-Type: text/csv; name="filename.csv"
    Content-Disposition: attachment; filename="filename.csv"
    

    In Windows browsers the MIME type is ignored after the file is downloaded and only file name extension is used to determine the corresponding application.

    Also, making .CSV file open in Excel correctly is hard, because the default separator is taken from Regional settings on the machine on which the CSV is opened. Furthermore, the encoding is not determined from the file content or MIME type, so any non-ASCII characters are hard to get working.

    0 讨论(0)
提交回复
热议问题