如何设置MIME类型为CSV文件,在打开电子表格应用程序(What to set as mimety

2019-07-04 23:52发布

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 OpenOffice, but some of my users complain that when they download the file, it does not open automatically Excel, but asks them to choose the application. When they download a CSV from some other site, it opens correctly in Excel.

I am setting:
mimetype: text/csv
content_disposition: attachment; filename.csv

Answer 1:

试试这个:

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

在Windows浏览器中的文件被下载,只有文件扩展名来确定相应的应用程序后的MIME类型被忽略。

此外,使.CSV文件在Excel中打开正确的是艰难的,因为默认的分隔符是从区域设置采取该CSV打开机器。 此外,编码是不是从文件内容或MIME类型决定的,因此任何非ASCII字符是很难得到工作。



文章来源: What to set as mimetype for CSV files to open in spreadsheet applications