我正在尝试使用 blob 类生成 CSV 文件。第一行工作正常,但其余行正在跳过第一列
var ExcelIndex = ['"user_name","user_hash","authenticate_id","first_name","last_name","description","department","phone_home","phone_mobile","phone_work","phone_other","phone_fax","address_street","address_city","address_state","address_country","address_postalcode","Errors"'];
var dataInSingleStringArray = new Array();
dataInSingleStringArray.push(ExcelIndex[0], "\n");
var ExcelInde = ['"user_name","user_hash","authenticate_id","first_name","last_name","description","department","phone_home","phone_mobile","phone_work","phone_other","phone_fax","address_street","address_city","address_state","address_country","address_postalcode","Errors"'];
// var dataInSingleStringArray = new Array();
dataInSingleStringArray.push(ExcelInde[0], "\n");
window.URL = window.webkitURL || window.URL;
var contentType = 'text/csv';
var csvFile = new Blob([dataInSingleStringArray], {type: contentType});
var a = document.createElement('a');
a.setAttribute("style", "margin-left: 700px;font-size: 2em;")
a.download = 'failed_data.csv';
a.href = window.URL.createObjectURL(csvFile);
a.textContent = 'Download File';
document.getElementById('link').appendChild(a);
<div id="link"></div>
呼唤远方
相关分类