Skip to content

Commit

Permalink
fix,untested: different method of shifting colInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
iyxan23 committed Sep 16, 2024
1 parent e6f6791 commit a413250
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/xlsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,14 @@ class XlsxTemplater {
} else if (shift.direction === "col") {
if (!colInfo) return;

for (const [key, val] of Object.entries(colInfo)) {
const keyNum = parseInt(key);
// shift infos that are over the current col, but duplicate the ones that
// is on the same col
if (keyNum === shift.col) {
for (let i = 0; i < shift.amount; i++) {
colInfo[keyNum + shift.amount] = val;
}
} else if (keyNum > shift.col) {
colInfo[keyNum + shift.amount] = val;
delete colInfo[keyNum];
}
// colInfo is different, rather than using indexes,
// it stores min & max in "@_min" and "@_max" respectively.
for (const col of colInfo) {
const min = col["@_min"];
const max = col["@_max"];

if (min >= shift.col) col["@_min"] += shift.amount;
if (max >= shift.col) col["@_max"] += shift.amount;
}
}

Expand Down

0 comments on commit a413250

Please sign in to comment.