fix: adjust the col numbers in extracted data
Build / Build-and-ng-test (pull_request) Failing after 18s
Details
Build / Build-and-ng-test (pull_request) Failing after 18s
Details
This commit is contained in:
parent
60510a4d68
commit
cff5989559
|
@ -385,34 +385,35 @@ export class XLMapComponent implements AfterContentInit, AfterViewInit, OnInit {
|
|||
const start = getCellAddress(rule.XLMAP_START, arrayOfObjects)
|
||||
const finish = getFinishingCell(start, rule.XLMAP_FINISH, arrayOfObjects)
|
||||
|
||||
const range = `${start}:${finish}`
|
||||
const a1Range = `${start}:${finish}`
|
||||
|
||||
const range = XLSX.utils.decode_range(a1Range)
|
||||
|
||||
const rangedData = <any[]>XLSX.utils.sheet_to_json(sheet, {
|
||||
raw: true,
|
||||
range: range,
|
||||
range: a1Range,
|
||||
header: 'A',
|
||||
blankrows: true
|
||||
})
|
||||
|
||||
for (let i = 0; i < rangedData.length; i++) {
|
||||
const row = rangedData[i]
|
||||
// Get the keys of the object (excluding '__rowNum__')
|
||||
const keys = Object.keys(row).filter((key) => key !== '__rowNum__')
|
||||
|
||||
for (let j = 0; j < keys.length; j++) {
|
||||
const key = keys[j]
|
||||
const val = row[key]
|
||||
for (let j = range.s.c, x = 0; j <= range.e.c; j++, x++) {
|
||||
const col = XLSX.utils.encode_col(j)
|
||||
|
||||
// in excel's R1C1 notation indexing starts from 1 but in JS it starts from 0
|
||||
// therefore, we'll have to add 1 to rows and cols
|
||||
extractedData.push({
|
||||
LOAD_REF: '0',
|
||||
XLMAP_ID: rule.XLMAP_ID,
|
||||
XLMAP_RANGE_ID: rule.XLMAP_RANGE_ID,
|
||||
ROW_NO: i + 1,
|
||||
COL_NO: j + 1,
|
||||
VALUE_TXT: val
|
||||
})
|
||||
if (col in row) {
|
||||
// in excel's R1C1 notation indexing starts from 1 but in JS it starts from 0
|
||||
// therefore, we'll have to add 1 to rows and cols
|
||||
extractedData.push({
|
||||
LOAD_REF: '0',
|
||||
XLMAP_ID: rule.XLMAP_ID,
|
||||
XLMAP_RANGE_ID: rule.XLMAP_RANGE_ID,
|
||||
ROW_NO: i + 1,
|
||||
COL_NO: x + 1,
|
||||
VALUE_TXT: row[col]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue