Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/core/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export class RangeAdapter implements CommandHandler<CoreCommand> {
let sheetName: string = "";
if (prefixSheet) {
if (rangeImpl.invalidSheetName) {
sheetName = rangeImpl.invalidSheetName;
sheetName = getCanonicalSheetName(rangeImpl.invalidSheetName);
} else {
sheetName = getCanonicalSheetName(this.getters.getSheetName(rangeImpl.sheetId));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/model/model_import_export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ describe("Migrations", () => {

const cfs = data.sheets[1].conditionalFormats;
const rule1 = cfs[0].rule as ColorScaleRule;
expect(cfs[0].ranges).toEqual(["=sheetName_!A1:A2"]);
expect(cfs[0].ranges).toEqual(["'=sheetName_'!A1:A2"]);
Copy link
Contributor Author

@hokolomopo hokolomopo Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole test is both totally broken, and it highlight some problematic behaviors:

Broken because:

  • in the spreadsheet data, it uses figure.type instead of figure.tag. So Charts are never actually created.
  • it creates a sheet with invalid characters in its name such as sheetName?, but the ranges of the charts/cfs are =sheetName!, an invalid sheet name that does not exist (notice the =, those are ranges and not formulas)

Strange behavior highlighted

  • cfs formulas are stored as string in the plugin, and exported as it in the data. So they never go though the createRange/toRangeString moulinette. So sheet name with wrong character are never escaped.

Not sure if we want/need to fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rrahir didn't we talk about this test sometime ? I kinda remember something like that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do recall that as well, I think we agreed to fix it in later versions (specifically when it came to introduce the carousel but I might be wrong) I don't recall what we put in place though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(rule1.minimum.value).toEqual("=sheetName_!B1");
expect(rule1.midpoint?.value).toEqual("=sheetName_!B1");
expect(rule1.maximum.value).toEqual("=sheetName_!B1");
Expand All @@ -298,7 +298,7 @@ describe("Migrations", () => {
expect(rule2.upperInflectionPoint.value).toEqual("=sheetName_!B1");

const rule3 = cfs[2].rule as ColorScaleRule;
expect(cfs[2].ranges).toEqual(["=sheetName_!A1:A2"]);
expect(cfs[2].ranges).toEqual(["'=sheetName_'!A1:A2"]);
expect(rule3.minimum.value).toEqual("33");
expect(rule3.midpoint?.value).toEqual("13");
expect(rule3.maximum.value).toBeUndefined();
Expand Down
9 changes: 7 additions & 2 deletions tests/range_plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,16 @@ describe("range plugin", () => {
}
);

test("invalid sheet name with special character", () => {
const range = m.getters.getRangeFromSheetXC("s1", "'Invalid Sheet Name'!A1");
expect(m.getters.getRangeString(range, "s1")).toBe("'Invalid Sheet Name'!A1");
});

test.each([
["s1!!!A1:A9", "'s1!!'!A1:A9"],
["'s1!!'!A1:A9", "'s1!!'!A1:A9"],
["s1!!!A1:s1!!!A9", "s1!!!A1:s1!!!A9"],
["s1!!!A1:s1!!!A9", "s1!!!A1:s1!!!A9"],
["s1!!!A1:s1!!!A9", "'s1!!!A1:s1!!'!A9"],
["s1!!!A1:s1!!!A9", "'s1!!!A1:s1!!'!A9"],
])(
"xc with more than one exclamation mark does not throw error",
(rangeString, expectedString) => {
Expand Down