diff --git a/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts b/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts
index 1fd00a2c839..9bc777b88b5 100644
--- a/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts
+++ b/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts
@@ -40,6 +40,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { FilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree';
import { FilteringLogic } from '../../data-operations/filtering-expression.interface';
import { IgxHierarchicalGridExportComponent,
+ IgxHierarchicalGridMCHCollapsibleComponent,
IgxHierarchicalGridMultiColumnHeaderIslandsExportComponent,
IgxHierarchicalGridMultiColumnHeadersExportComponent,
IgxHierarchicalGridSummariesExportComponent
@@ -1013,6 +1014,27 @@ describe('Excel Exporter', () => {
await exportAndVerify(hGrid, options, actualData.exportEmptyMultiColumnHeadersDataWithExportedHeaders);
});
+
+ it('should export collapsible MCH with visibleWhenCollapsed set on 2 columns with the same field', async () => {
+ const fix = TestBed.createComponent(IgxHierarchicalGridMCHCollapsibleComponent);
+ fix.detectChanges();
+
+ const hGrid = fix.componentInstance.hGrid;
+ GridFunctions.clickGroupExpandIndicator(fix, hGrid.columnList.get(1));
+ fix.detectChanges();
+
+ const firstRow = hGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
+ UIInteractions.simulateClickAndSelectEvent(firstRow.expander);
+ fix.detectChanges();
+
+ const rowIsland = hGrid.childLayoutList.first;
+ GridFunctions.clickGroupExpandIndicator(fix, rowIsland.columnList.get(1));
+ fix.detectChanges();
+
+
+ options = createExportOptions('HierarchicalGridCollapsibleMCHExcelExport');
+ await exportAndVerify(hGrid, options, actualData.exportHierarchicalDataWithCollapsibleMCH);
+ })
});
describe('', () => {
diff --git a/projects/igniteui-angular/src/lib/services/excel/test-data.service.spec.ts b/projects/igniteui-angular/src/lib/services/excel/test-data.service.spec.ts
index ede6cc673ea..d03e1bd864b 100644
--- a/projects/igniteui-angular/src/lib/services/excel/test-data.service.spec.ts
+++ b/projects/igniteui-angular/src/lib/services/excel/test-data.service.spec.ts
@@ -1283,6 +1283,20 @@ export class FileContentData {
return this.createData();
}
+ public get exportHierarchicalDataWithCollapsibleMCH() {
+ this._sharedStringsData =
+ `count="53" uniqueCount="38">IDLocationCityALFKIBerlinCompanyNamePersonal DetailsContactNameContactTitleAna Trujillo Emparedados y heladosAna TrujilloOwnerAntonio Moreno TaqueríaAntonio MorenoCOMMISao PauloConsolidated HoldingsElizabeth BrownSales RepresentativeDrachenblut DelikatessenSven OttliebOrder AdministratorDu monde entierJanine LabruneFISSAMadridFolies gourmandesMartine RancéAssistant Sales AgentFolk och fä HBMaria LarssonFrankenversandPeter FrankenMarketing ManagerFrance restaurationCarine SchmittFRANSTorino`;
+
+ this._worksheetData =
+ `
+
+
+
+ 01
2
34
56
578
91011
121311
1415
56
578
161718
192021
222311
2425
56
578
262728
293011
313233
343533
3637
`;
+
+ return this.createData();
+ }
+
public get exportMultiColumnHeadersData() {
this._sharedStringsData =
`count="195" uniqueCount="162">IDGeneral InformationAddress InformationPersonal DetailsLocationContact InformationContactNameContactTitleCountryPhoneFaxPostalCodeALFKIMaria AndersSales RepresentativeGermany030-0074321030-007654512209ANATRAna TrujilloOwnerMexico(5) 555-4729(5) 555-374505021ANTONAntonio Moreno(5) 555-393205023AROUTThomas HardyUK(171) 555-7788(171) 555-6750WA1 1DPBERGSChristina BerglundOrder AdministratorSweden0921-12 34 650921-12 34 67S-958 22BLAUSHanna Moos0621-084600621-0892468306BLONPFrédérique CiteauxMarketing ManagerFrance88.60.15.3188.60.15.3267000BOLIDMartín SommerSpain(91) 555 22 82(91) 555 91 9928023BONAPLaurence Lebihan91.24.45.4091.24.45.4113008BOTTMElizabeth LincolnAccounting ManagerCanada(604) 555-4729(604) 555-3745T2F 8M4BSBEVVictoria Ashworth(171) 555-1212EC2 5NTCACTUPatricio SimpsonSales AgentArgentina(1) 135-5555(1) 135-48921010CENTCFrancisco Chang(5) 555-3392(5) 555-729305022CHOPSYang WangSwitzerland0452-0765453012COMMIPedro AfonsoSales AssociateBrazil(11) 555-764705432-043CONSHElizabeth Brown(171) 555-2282(171) 555-9199WX1 6LTDRACDSven Ottlieb0241-0391230241-05942852066DUMONJanine Labrune40.67.88.8840.67.89.8944000EASTCAnn Devon(171) 555-0297(171) 555-3373WX3 6FWERNSHRoland MendelSales ManagerAustria7675-34257675-34268010FAMIAAria CruzMarketing Assistant(11) 555-985705442-030FISSADiego Roel(91) 555 94 44(91) 555 55 9328034FOLIGMartine RancéAssistant Sales Agent20.16.10.1620.16.10.1759000FOLKOMaria Larsson0695-34 67 21S-844 67FRANKPeter Franken089-0877310089-087745180805FRANRCarine Schmitt40.32.21.2140.32.21.20FRANSPaolo AccortiItaly011-4988260011-498826110100`;
diff --git a/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts b/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts
index ef505ec7ca7..31fe7f6f1ef 100644
--- a/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts
+++ b/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts
@@ -43,6 +43,7 @@ export interface IExportRecord {
hidden?: boolean;
summaryKey?: string;
hierarchicalOwner?: string;
+ references?: IColumnInfo[];
}
export interface IColumnList {
@@ -484,8 +485,7 @@ export abstract class IgxBaseExporter {
return a;
}, {});
} else {
- const filteredHeaders = ownerCols.filter(c => c.skip).map(c => c.header ? c.header : c.field);
- record.data = record.data.filter(d => filteredHeaders.indexOf(d) === -1);
+ record.data = record.data.filter((_, i) => !record.references[i].skip)
}
}
@@ -762,9 +762,8 @@ export abstract class IgxBaseExporter {
childData: any[], expansionStateVal: boolean, grid: GridType) {
const hierarchicalOwner = `${GRID_CHILD}${++this.rowIslandCounter}`;
const columnList = this._ownersMap.get(island).columns;
- const columnHeader = columnList
- .filter(col => col.headerType === ExportHeaderType.ColumnHeader)
- .map(col => col.header ? col.header : col.field);
+ const columnHeaders = columnList.filter(col => col.headerType === ExportHeaderType.ColumnHeader);
+ const columnHeader = columnHeaders.map(col => col.header ? col.header : col.field);
const headerRecord: IExportRecord = {
data: columnHeader,
@@ -772,6 +771,7 @@ export abstract class IgxBaseExporter {
type: ExportRecordType.HeaderRecord,
owner: island,
hidden: !expansionStateVal,
+ references: columnHeaders,
hierarchicalOwner
};
diff --git a/projects/igniteui-angular/src/lib/test-utils/hierarchical-grid-components.spec.ts b/projects/igniteui-angular/src/lib/test-utils/hierarchical-grid-components.spec.ts
index 4ddca66997c..28bd50a35a5 100644
--- a/projects/igniteui-angular/src/lib/test-utils/hierarchical-grid-components.spec.ts
+++ b/projects/igniteui-angular/src/lib/test-utils/hierarchical-grid-components.spec.ts
@@ -579,6 +579,33 @@ export class IgxHierarchicalGridMultiColumnHeadersExportComponent {
public data = HIERARCHICAL_SAMPLE_DATA;
}
+@Component({
+ template: `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `,
+ standalone: true,
+ imports: [IgxHierarchicalGridComponent, IgxColumnComponent, IgxColumnGroupComponent, IgxRowIslandComponent]
+})
+export class IgxHierarchicalGridMCHCollapsibleComponent {
+ @ViewChild('hierarchicalGrid', { read: IgxHierarchicalGridComponent, static: true }) public hGrid: IgxHierarchicalGridComponent;
+ public data = HIERARCHICAL_SAMPLE_DATA;
+}
+
@Component({
template: `