I use SheetJS to export data to excel and looks like excel itself repair data. Data download good, but is it ok to receive this warning?
I've got and file.xlsx from UI, and when I open it via excel I received some warning was produced by Excel itself.
Code:
const download = (url, name) => {
let a = document.createElement('a')
a.href = url
a.download = name
a.click()
window.URL.revokeObjectURL(url)
}
function Workbook() {
if (!(this instanceof Workbook))
return new Workbook()
this.SheetNames = []
this.Sheets = {}
}
function s2ab(s) {
const buf = new ArrayBuffer(s.length)
const view = new Uint8Array(buf)
for (let i=0; i !== s.length; ++i)
view[i] = s.charCodeAt(i) & 0xFF
return view
}
export default data => {
import('xlsx').then(XLSX => {
const wb = new Workbook()
const ws = XLSX.utils.json_to_sheet(data)
wb.SheetNames.push('s')
wb.Sheets[''] = ws
const wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'})
let url = window.URL.createObjectURL(new Blob([s2ab(wbout)], {type:'application/octet-stream'}))
download(url, 'import.xlsx')
})
}