Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ import { IgxHierarchicalGridExportComponent,
import { IgxHierarchicalGridComponent } from '../../grids/hierarchical-grid/public_api';
import { IgxHierarchicalRowComponent } from '../../grids/hierarchical-grid/hierarchical-row.component';
import { GridFunctions } from '../../test-utils/grid-functions.spec';
import { IgxPivotGridMultipleRowComponent, IgxPivotGridTestComplexHierarchyComponent } from '../../test-utils/pivot-grid-samples.spec';
import { IgxPivotGridComponent, PivotRowLayoutType } from '../../grids/pivot-grid/public_api';
import { IgxPivotGridMultipleRowComponent, IgxPivotGridTestComplexHierarchyComponent, SALES_DATA } from '../../test-utils/pivot-grid-samples.spec';
import { IgxPivotGridComponent, IgxPivotNumericAggregate, PivotRowLayoutType } from '../../grids/pivot-grid/public_api';

describe('Excel Exporter', () => {
configureTestSuite();
Expand Down Expand Up @@ -1458,7 +1458,7 @@ describe('Excel Exporter', () => {
let grid: IgxPivotGridComponent;

beforeEach(waitForAsync(() => {
options = createExportOptions('PivotGridGridExcelExport');
options = createExportOptions('PivotGridExcelExport');
}));

it('should export pivot grid', async () => {
Expand All @@ -1483,6 +1483,80 @@ describe('Excel Exporter', () => {
await exportAndVerify(grid, options, actualData.exportPivotGridDataWithHeaders, false);
});

it('should export pivot grid with hierarchical row dimensions.', async () => {
fix = TestBed.createComponent(IgxPivotGridMultipleRowComponent);
fix.detectChanges();

grid = fix.componentInstance.pivotGrid;
fix.componentInstance.data = SALES_DATA;
fix.componentInstance.pivotConfigHierarchy = {
rows: [
{
memberName: 'All_Srep Code Alts',
enabled: true,
width: '150px',
childLevel: {
memberName: 'SREP_CODE_ALT',
displayName: 'Srep Code Alt',
sortDirection: 1,
enabled: true,
},
},
{
memberName: 'All_Srep Codes',
enabled: true,
width: '150px',
childLevel: {
memberName: 'SREP_CODE',
displayName: 'Srep Code',
sortDirection: 1,
enabled: true,
},
},
{
memberName: 'All_Customers',
enabled: true,
width: '150px',
childLevel: {
memberName: 'CUST_CODE',
displayName: 'Customer',
sortDirection: 1,
enabled: true,
},
}
],
columns: [],
values: [
{
member: 'JOBS',
aggregate: {
key: 'Count of Jobs',
aggregator: IgxPivotNumericAggregate.count,
label: 'Count of Jobs',
},
enabled: true,
dataType: 'number',
},
{
member: 'INV_SALES',
aggregate: {
key: 'Sum of Sales',
aggregator: IgxPivotNumericAggregate.sum,
label: 'Sum of Sales',
},
enabled: true,
dataType: 'number',
},
],
filters: [],
};
grid.pivotUI.showRowHeaders = true;
fix.detectChanges();
await wait(300);

await exportAndVerify(grid, options, actualData.exportPivotGridHierarchicalRowDimensions, false);
});

it('should export hierarchical pivot grid', async () => {
fix = TestBed.createComponent(IgxPivotGridTestComplexHierarchyComponent);
fix.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ export class WorksheetFile implements IExcelFile {
for (const currentCol of headersForLevel) {
const spanLength = isVertical ? currentCol.rowSpan : currentCol.columnSpan;

if (currentCol.level === i && currentCol.headerType !== ExportHeaderType.PivotMergedHeader) {
if (currentCol.level === i) {
let columnCoordinate;
const column = isVertical
? this.rowIndex
Expand All @@ -644,7 +644,10 @@ export class WorksheetFile implements IExcelFile {
if (currentCol.headerType === ExportHeaderType.PivotRowHeader) {
rowCoordinate = startValue + 1;
}
const columnValue = dictionary.saveValue(currentCol.header, true, false);

const columnValue = currentCol.headerType === ExportHeaderType.PivotMergedHeader ?
dictionary.saveValue(currentCol.field, true, true) :
dictionary.saveValue(currentCol.header, true, false);

columnCoordinate = (currentCol.field === GRID_LEVEL_COL
? ExcelStrings.getExcelColumn(worksheetData.columnCount + 1)
Expand Down
Loading
Loading