设置为mimetype的csv文件在电子表格应用程序中打开的设置(What to set as mimetype for csv files to open in spreadsheet applications)

963 IT屋

我的应用程序允许用户将其数据下载为csv文件。这些应该在电子表格应用程序中打开。在linux系统上,我得到提示正确打开与OpenOffice。但是我的一些用户抱怨,当他们下载文件,它不会自动打开excel,但要求他们选择的应用程序。当他们从其他网站下载csv时,它在excel中正确打开。



我设置:

mimetype:text / csv

content_disposition:attachment; filename.csv


解决方案

尝试:



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


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



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


My application lets user 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 doesnot open automatically excel, but asks them to choose the application. When they download a csv from someother site it opens correctly in excel.

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

解决方案

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.

本文地址:IT屋 » 设置为mimetype的csv文件在电子表格应用程序中打开的设置

相关文章: