Я установил content_type
и to_csv
encoding
как utf_8_sig
response = HttpResponse(content_type='text/csv;charset=utf_8_sig')
response['Content-Disposition'] = 'attachment; filename=somefilename.csv'
df.to_csv(path_or_buf=response,sep=',',float_format='%.2f',index=False,decimal=",",encoding='utf_8_sig')
, а затем
отправил csv пользователю в javascript
//ajax response
DownlodCsv(response);
const DownloadCsv = (function() {
const a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function(data, fileName) {
const blob = new Blob([data], {type: "octet/stream"}),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
Однако это все еще utf-8
не utf-8-sig
(потому что я не могу открыть это через excel)
Есть ли место, где я должен проверить ?????