Js前端导出csv
var myMemory = myObjectStore.objectStore; var myDataArray = myMemory.data; var myCsvString = "\ufeff" var myPropertyNameArray = []; var myDataGridLayout = myThis._DataGrid.structure; var myPropertyCount = myDataGridLayout[0].cells.length; for (var i = 0; i < myPropertyCount; i++) { myCsvString += myDataGridLayout[0].cells[i].name + ","; myPropertyNameArray.push(myDataGridLayout[0].cells[i].field); } myCsvString += '\r\n'; for (var i = 0; i < myDataArray.length; i++) { for (var j = 0; j < myPropertyNameArray.length; j++) { myCsvString += myDataArray[i][myPropertyNameArray[j]] + ","; } myCsvString += '\r\n'; } var myCsvData = new Blob([myCsvString], { type: "text/csv,charset=UTF-8" }); var myCsvUrl = URL.createObjectURL(myCsvData); var myUIA = document.createElement("a"); myUIA.setAttribute("href", myCsvUrl); myUIA.setAttribute("download", "data.csv"); myUIA.click();