Fixing Defined Range Name with Sheet Name (#150)

* fixing defined range name with sheetname
* add test for _xlnm.Print_Titles named range

Co-authored-by: Ade Pangestu <ade.pangestu@mitrais.com>
This commit is contained in:
Ade Pangestu
2022-02-14 18:02:38 +07:00
committed by GitHub
parent 752568a81d
commit da61b0d5e5
3 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -830,11 +830,11 @@ module.exports = (function() {
// Split a reference into an object with keys `row` and `col` and,
// optionally, `table`, `rowAbsolute` and `colAbsolute`.
Workbook.prototype.splitRef = function(ref) {
var match = ref.match(/(?:(.+)!)?(\$)?([A-Z]+)(\$)?([0-9]+)/);
var match = ref.match(/(?:(.+)!)?(\$)?([A-Z]+)?(\$)?([0-9]+)/);
return {
table: match && match[1] || null,
colAbsolute: Boolean(match && match[2]),
col: match && match[3],
col: match && match[3] || "",
rowAbsolute: Boolean(match && match[4]),
row: parseInt(match && match[5], 10)
};
+1
View File
@@ -667,6 +667,7 @@ describe("CRUD operations", function() {
expect(workbook.find("./definedNames/definedName[@name='RangeBelowTable']").text).toEqual("Tables!$B$19:$C$19");
expect(workbook.find("./definedNames/definedName[@name='RangeRightOfTable']").text).toEqual("Tables!$E$14:$F$14");
expect(workbook.find("./definedNames/definedName[@name='RightOfTable']").text).toEqual("Tables!$F$8");
expect(workbook.find("./definedNames/definedName[@name='_xlnm.Print_Titles']").text).toEqual("Tables!$1:$3");
// Merged cells have moved
expect(sheet1.find("./mergeCells/mergeCell[@ref='B2:C2']")).not.toBeNull(); // title - unchanged
Binary file not shown.