Browse Source

fix: exclude date1904 fix from csv quick import

pull/2357/head
Wing-Kam Wong 3 years ago
parent
commit
7eec85dcfc
  1. 6
      packages/nc-gui/components/import/templateParsers/ExcelTemplateAdapter.js

6
packages/nc-gui/components/import/templateParsers/ExcelTemplateAdapter.js

@ -46,8 +46,9 @@ export default class ExcelTemplateAdapter extends TemplateGenerator {
this.data[tn] = []
const ws = this.wb.Sheets[sheet]
const range = XLSX.utils.decode_range(ws['!ref'])
const originalRows = XLSX.utils.sheet_to_json(ws, { header: 1, blankrows: false, cellDates: true, defval: null })
const rows = XLSX.utils.sheet_to_json(ws, { header: 1, blankrows: false, cellDates: true, defval: null })
if (this.name.slice(-3) !== 'csv') {
// fix precision bug & timezone offset issues introduced by xlsx
const basedate = new Date(1899, 11, 30, 0, 0, 0)
// number of milliseconds since base date
@ -62,9 +63,10 @@ export default class ExcelTemplateAdapter extends TemplateGenerator {
return new Date(parsed.y, parsed.m, parsed.d, parsed.H, parsed.M, parsed.S)
}
// fix imported date
const rows = originalRows.map(r => r.map((v) => {
rows = rows.map(r => r.map((v) => {
return v instanceof Date ? fixImportedDate(v) : v
}))
}
const columnNameRowExist = +rows[0].every(v => v === null || typeof v === 'string')

Loading…
Cancel
Save