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/spreadsheet_pivot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class SpreadsheetPivotCorePlugin extends CorePlugin {
const adaptedRange = adaptPivotRange(range, applyChange);

if (adaptedRange === range) {
return;
continue;
}

const dataSet = adaptedRange && {
Expand Down
17 changes: 17 additions & 0 deletions tests/pivots/spreadsheet_pivot/spreadsheet_pivot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CellErrorType, FunctionResultObject, Model } from "../../../src";
import { resetMapValueDimensionDate } from "../../../src/helpers/pivot/spreadsheet_pivot/date_spreadsheet_pivot";
import { DEFAULT_LOCALES } from "../../../src/types/locale";
import {
addColumns,
addRows,
createSheet,
deleteContent,
Expand Down Expand Up @@ -667,6 +668,22 @@ describe("Spreadsheet Pivot", () => {
expect(getEvaluatedCell(model, "A27").value).toEqual("(#1) My pivot");
});

test("Each pivot is adapted following a sheet structure change", () => {
const model = createModelWithPivot("A1:F5");
addPivot(model, "G1:I5", {}, "2");
const sheetId = model.getters.getActiveSheetId();
createSheet(model, { activate: true });
setCellContent(model, "A1", `=pivot(1)`);
setCellContent(model, "A50", `=pivot(2)`);
expect(model.getters.getPivot("1").isValid()).toBeTruthy();
expect(model.getters.getPivot("2").isValid()).toBeTruthy();
expect(getEvaluatedCell(model, "A1").value).toEqual("(#1) My pivot");
expect(getEvaluatedCell(model, "A50").value).toEqual("(#2) Pivot");
addColumns(model, "before", "G", 1, sheetId);
expect(model.getters.getPivot("1").isValid()).toBeTruthy();
expect(model.getters.getPivot("2").isValid()).toBeTruthy();
});

test("Sum with a field that contains a string should work", () => {
const model = createModelWithPivot("A1:I5");
updatePivot(model, "1", {
Expand Down