diff --git a/packages/devextreme/js/__internal/exporter/exceljs/export_pivot_grid.ts b/packages/devextreme/js/__internal/exporter/exceljs/export_pivot_grid.ts index ab5007f37300..2d9d4c28e307 100644 --- a/packages/devextreme/js/__internal/exporter/exceljs/export_pivot_grid.ts +++ b/packages/devextreme/js/__internal/exporter/exceljs/export_pivot_grid.ts @@ -164,7 +164,7 @@ class PivotGridHelpers { } const fields = this._getAllFieldHeaders()[area === 'data' ? 'values' : `${area}s`] - .filter((fieldHeader) => fieldHeader.area === area); + .filter((fieldHeader) => fieldHeader.area === area && fieldHeader.visible !== false); if (getDefaultAlignment(this.rtlEnabled) === 'right') { fields.sort((a, b) => b.areaIndex - a.areaIndex); diff --git a/packages/devextreme/testing/tests/DevExpress.exporter/exceljsParts/exceljs.pivotGrid.tests.js b/packages/devextreme/testing/tests/DevExpress.exporter/exceljsParts/exceljs.pivotGrid.tests.js index e36a91135f60..2307510f36b5 100644 --- a/packages/devextreme/testing/tests/DevExpress.exporter/exceljsParts/exceljs.pivotGrid.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.exporter/exceljsParts/exceljs.pivotGrid.tests.js @@ -7829,6 +7829,38 @@ QUnit.module('Scenarios', moduleConfig, () => { done(); }); }); + + // T1325416 - Fields with visible:false should not be exported in field headers + QUnit.test('Data fields with visible:false should not be exported in data field headers', function(assert) { + const done = assert.async(); + const ds = { + fields: [ + { area: 'row', dataField: 'row' }, + { area: 'data', dataField: 'Sales', summaryType: 'sum', caption: 'Sales', visible: true }, + { area: 'data', dataField: 'Sales2', summaryType: 'sum', caption: 'Sales2', visible: false }, + { area: 'data', dataField: 'Sales3', summaryType: 'sum', caption: 'Sales3', visible: false } + ], + store: [] + }; + const pivotGrid = $('#pivotGrid').dxPivotGrid({ dataSource: ds }).dxPivotGrid('instance'); + + exportPivotGrid({ + component: pivotGrid, + worksheet: this.worksheet, + topLeftCell: topLeft, + exportDataFieldHeaders: true + }).then(() => { + const dataFieldHeaderCell = this.worksheet.getRow(topLeft.row).getCell(topLeft.column); + const cellValue = dataFieldHeaderCell.value; + + assert.strictEqual(cellValue, 'Sales', `Data field header should show 'Sales', got: '${cellValue}'`); + + assert.ok(!cellValue.includes('Sales2'), 'Data field header should not contain Sales2'); + assert.ok(!cellValue.includes('Sales3'), 'Data field header should not contain Sales3'); + done(); + }); + }); + }); }); @@ -8074,7 +8106,6 @@ ExcelJSLocalizationFormatTests.runPivotGridCurrencyTests([ ]); ExcelJSOptionTests.runTests(moduleConfig, exportPivotGrid.__internals._getFullOptions, () => $('#pivotGrid').dxPivotGrid({}).dxPivotGrid('instance')); - [ { enabled: true }, { enabled: false },