| | |
| | | const firstSheetName = workbook.SheetNames[0] |
| | | const worksheet = workbook.Sheets[firstSheetName] |
| | | const header = this.getHeaderRow(worksheet) |
| | | const results = XLSX.utils.sheet_to_json(worksheet) |
| | | const results = XLSX.utils.sheet_to_json(worksheet, { range: 1 }) |
| | | this.generateData({ header, results }) |
| | | this.loading = false |
| | | resolve() |
| | |
| | | const range = XLSX.utils.decode_range(sheet['!ref']) |
| | | let C |
| | | const R = range.s.r |
| | | console.log('111111111111111111111 : ', R) |
| | | /* start in the first row */ |
| | | for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */ |
| | | console.log('XLSX.utils.encode_cell({ c: C, r: R }) : ', XLSX.utils.encode_cell({ c: C, r: R })) |
| | | const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })] |
| | | const cell2 = sheet[XLSX.utils.encode_cell({ c: C, r: R + 1 })] |
| | | /* find the cell in the first row */ |
| | | let hdr = 'UNKNOWN ' + C // <-- replace with your desired default |
| | | if (cell && cell.t) hdr = XLSX.utils.format_cell(cell) |
| | | const hdr = { id: 'UNKNOWN ' + C, name: 'UNKNOWN ' + C } // <-- replace with your desired default |
| | | if (cell && cell.t) hdr.name = XLSX.utils.format_cell(cell) |
| | | if (cell2 && cell2.t) hdr.id = XLSX.utils.format_cell(cell2) |
| | | headers.push(hdr) |
| | | } |
| | | return headers |