Skip to content

Commit 2a1eb8e

Browse files
committed
Adjust named range parsing to ignore temporary workbook indexes
The latest version of the PnP has named ranges like ``` [1]SheetName!A1 ``` These brackets typically refer to the file paths of external workbooks. But when Excel has multiple workbooks open, it can assign a temporary index here as well. These can be safely ignored.
1 parent 9741ab9 commit 2a1eb8e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/common/xlsx.util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export class WorkBook {
5757
@Once() private get namedRanges(): Record<string, Range> {
5858
const rawList = this.book.Workbook?.Names ?? [];
5959
return mapEntries(rawList, ({ Ref: ref, Name: name }, { SKIP }) => {
60-
const matched = /^'?([^']+)'?!([$\dA-Z]+(?::[$\dA-Z]+)?)$/.exec(ref);
60+
const matched =
61+
/^(?:\[\d+])?'?([^']+)'?!([$\dA-Z]+(?::[$\dA-Z]+)?)$/.exec(ref);
6162
if (!matched) {
6263
return SKIP;
6364
}

0 commit comments

Comments
 (0)