igniteui-angular 14.2.0-alpha.3 → 14.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,9 +8,9 @@ import * as i1$1 from '@angular/common';
8
8
  import { isPlatformBrowser, formatDate as formatDate$1, CurrencyPipe, formatPercent, formatNumber, getLocaleCurrencyCode, DatePipe, DOCUMENT, CommonModule, FormatWidth, getLocaleDateFormat, getLocaleFirstDayOfWeek, getLocaleCurrencySymbol, formatCurrency as formatCurrency$1, getLocaleNumberFormat, NumberFormatStyle, getCurrencySymbol } from '@angular/common';
9
9
  import { Observable, Subject, fromEvent, interval, animationFrameScheduler, noop, merge, Subscription, timer, pipe } from 'rxjs';
10
10
  import { takeUntil, filter, first as first$1, throttleTime, take, throttle, startWith, debounce, tap, switchMap, skipLast, map, debounceTime, shareReplay, takeWhile, pluck } from 'rxjs/operators';
11
- import mergeWith from 'lodash.mergewith';
11
+ import { mergeWith } from 'lodash-es';
12
12
  import { __awaiter, __decorate, __param } from 'tslib';
13
- import * as JSZip from 'jszip';
13
+ import { strToU8, zip } from 'fflate';
14
14
  import * as i1$2 from '@angular/platform-browser';
15
15
  import { HammerGestureConfig, HAMMER_GESTURE_CONFIG, ɵgetDOM } from '@angular/platform-browser';
16
16
  import * as i2 from '@angular/common/http';
@@ -2543,10 +2543,13 @@ var ExportRecordType;
2543
2543
  ExportRecordType["DataRecord"] = "DataRecord";
2544
2544
  ExportRecordType["HierarchicalGridRecord"] = "HierarchicalGridRecord";
2545
2545
  ExportRecordType["HeaderRecord"] = "HeaderRecord";
2546
+ ExportRecordType["PivotGridRecord"] = "PivotGridRecord";
2546
2547
  })(ExportRecordType || (ExportRecordType = {}));
2547
2548
  var HeaderType;
2548
2549
  (function (HeaderType) {
2550
+ HeaderType["RowHeader"] = "RowHeader";
2549
2551
  HeaderType["ColumnHeader"] = "ColumnHeader";
2552
+ HeaderType["MultiRowHeader"] = "MultiRowHeader";
2550
2553
  HeaderType["MultiColumnHeader"] = "MultiColumnHeader";
2551
2554
  })(HeaderType || (HeaderType = {}));
2552
2555
  /**hidden
@@ -2602,6 +2605,8 @@ class IgxBaseExporter {
2602
2605
  this._sort = null;
2603
2606
  this._ownersMap = new Map();
2604
2607
  this.flatRecords = [];
2608
+ this.pivotGridColumns = [];
2609
+ this.pivotGridKeyValueMap = new Map();
2605
2610
  }
2606
2611
  /**
2607
2612
  * Method for exporting IgxGrid component's data.
@@ -2616,6 +2621,7 @@ class IgxBaseExporter {
2616
2621
  throw Error('No options provided!');
2617
2622
  }
2618
2623
  this.options = options;
2624
+ this.locale = grid.locale;
2619
2625
  let columns = grid.columns;
2620
2626
  if (this.options.ignoreMultiColumnHeaders) {
2621
2627
  columns = columns.filter(col => col.children === undefined);
@@ -2629,10 +2635,21 @@ class IgxBaseExporter {
2629
2635
  this.mapHierarchicalGridColumns(island, grid.data[0]);
2630
2636
  }
2631
2637
  }
2638
+ else if (tagName === 'igx-pivot-grid') {
2639
+ this.pivotGridColumns = [];
2640
+ this.isPivotGridExport = true;
2641
+ this.pivotGridKeyValueMap = new Map();
2642
+ this.pivotGridRowDimensionsMap = new Map();
2643
+ grid.pivotConfiguration.rows.filter(r => r.enabled).forEach(rowDimension => {
2644
+ this.addToRowDimensionsMap(rowDimension, rowDimension.memberName);
2645
+ });
2646
+ this._ownersMap.set(DEFAULT_OWNER, columnList);
2647
+ }
2632
2648
  else {
2633
2649
  this._ownersMap.set(DEFAULT_OWNER, columnList);
2634
2650
  }
2635
2651
  this.prepareData(grid);
2652
+ this.addPivotGridColumns(grid);
2636
2653
  this.exportGridRecordsData(this.flatRecords, grid);
2637
2654
  }
2638
2655
  /**
@@ -2658,6 +2675,12 @@ class IgxBaseExporter {
2658
2675
  });
2659
2676
  this.exportGridRecordsData(records);
2660
2677
  }
2678
+ addToRowDimensionsMap(rowDimension, rootParentName) {
2679
+ this.pivotGridRowDimensionsMap[rowDimension.memberName] = rootParentName;
2680
+ if (rowDimension.childLevel) {
2681
+ this.addToRowDimensionsMap(rowDimension.childLevel, rootParentName);
2682
+ }
2683
+ }
2661
2684
  exportGridRecordsData(records, grid) {
2662
2685
  var _a;
2663
2686
  if (this._ownersMap.size === 0) {
@@ -2769,7 +2792,7 @@ class IgxBaseExporter {
2769
2792
  const ownerCols = this._ownersMap.get(owner).columns;
2770
2793
  if (record.type !== ExportRecordType.HeaderRecord) {
2771
2794
  const columns = ownerCols
2772
- .filter(c => c.headerType !== HeaderType.MultiColumnHeader && !c.skip)
2795
+ .filter(c => c.headerType !== HeaderType.MultiColumnHeader && c.headerType !== HeaderType.RowHeader && c.headerType !== HeaderType.MultiRowHeader && !c.skip)
2773
2796
  .sort((a, b) => a.startIndex - b.startIndex)
2774
2797
  .sort((a, b) => a.pinnedIndex - b.pinnedIndex);
2775
2798
  record.data = columns.reduce((a, e) => {
@@ -2786,7 +2809,14 @@ class IgxBaseExporter {
2786
2809
  else if (e.dataType === 'string' && rawValue instanceof Date) {
2787
2810
  rawValue = rawValue.toString();
2788
2811
  }
2789
- a[e.field] = shouldApplyFormatter ? e.formatter(rawValue) : rawValue;
2812
+ else if (e.dataType === 'currency') {
2813
+ rawValue = formatCurrency(rawValue, e.currencyCode, e.displayFormat, e.digitsInfo, this.locale);
2814
+ }
2815
+ let formattedValue = shouldApplyFormatter ? e.formatter(rawValue) : rawValue;
2816
+ if (this.isPivotGridExport && !isNaN(parseFloat(formattedValue))) {
2817
+ formattedValue = parseFloat(formattedValue);
2818
+ }
2819
+ a[e.field] = formattedValue;
2790
2820
  }
2791
2821
  return a;
2792
2822
  }, {});
@@ -2848,6 +2878,10 @@ class IgxBaseExporter {
2848
2878
  const expressions = grid.groupingExpressions ? grid.groupingExpressions.concat(grid.sortingExpressions || []) : grid.sortingExpressions;
2849
2879
  const hasSorting = expressions && expressions.length > 0;
2850
2880
  switch (tagName) {
2881
+ case 'igx-pivot-grid': {
2882
+ this.preparePivotGridData(grid);
2883
+ break;
2884
+ }
2851
2885
  case 'igx-hierarchical-grid': {
2852
2886
  this.prepareHierarchicalGridData(grid, hasFiltering, hasSorting);
2853
2887
  break;
@@ -2862,6 +2896,21 @@ class IgxBaseExporter {
2862
2896
  }
2863
2897
  }
2864
2898
  }
2899
+ preparePivotGridData(grid) {
2900
+ for (const record of grid.filteredSortedData) {
2901
+ const recordData = Object.fromEntries(record.aggregationValues);
2902
+ record.dimensionValues.forEach((value, key) => {
2903
+ const actualKey = this.pivotGridRowDimensionsMap[key];
2904
+ recordData[actualKey] = value;
2905
+ });
2906
+ const pivotGridRecord = {
2907
+ data: recordData,
2908
+ level: record.level,
2909
+ type: ExportRecordType.PivotGridRecord
2910
+ };
2911
+ this.flatRecords.push(pivotGridRecord);
2912
+ }
2913
+ }
2865
2914
  prepareHierarchicalGridData(grid, hasFiltering, hasSorting) {
2866
2915
  const skipOperations = (!hasFiltering || !this.options.ignoreFiltering) &&
2867
2916
  (!hasSorting || !this.options.ignoreSorting);
@@ -3199,6 +3248,17 @@ class IgxBaseExporter {
3199
3248
  columnGroupParent: column.parent ? column.parent : null,
3200
3249
  columnGroup: isMultiColHeader ? column : null
3201
3250
  };
3251
+ if (column.dataType === 'currency') {
3252
+ columnInfo.currencyCode = column.pipeArgs.currencyCode
3253
+ ? column.pipeArgs.currencyCode
3254
+ : getLocaleCurrencyCode(this.locale);
3255
+ columnInfo.displayFormat = column.pipeArgs.display
3256
+ ? column.pipeArgs.display
3257
+ : 'symbol';
3258
+ columnInfo.digitsInfo = column.pipeArgs.digitsInfo
3259
+ ? column.pipeArgs.digitsInfo
3260
+ : '1.0-2';
3261
+ }
3202
3262
  if (this.options.ignoreColumnsOrder) {
3203
3263
  if (columnInfo.startIndex !== columnInfo.pinnedIndex) {
3204
3264
  columnInfo.pinnedIndex = Number.MAX_VALUE;
@@ -3287,6 +3347,68 @@ class IgxBaseExporter {
3287
3347
  };
3288
3348
  return result;
3289
3349
  }
3350
+ addPivotGridColumns(grid) {
3351
+ if (grid.nativeElement.tagName.toLowerCase() !== 'igx-pivot-grid') {
3352
+ return;
3353
+ }
3354
+ const enabledRows = grid.pivotConfiguration.rows.filter(r => r.enabled).map((r, i) => ({ name: r.memberName, level: i }));
3355
+ this.preparePivotGridColumns(enabledRows);
3356
+ this.pivotGridFilterFieldsCount = enabledRows.length;
3357
+ const columnList = this._ownersMap.get(DEFAULT_OWNER);
3358
+ columnList.columns.unshift(...this.pivotGridColumns);
3359
+ columnList.columnWidths.unshift(...Array(this.pivotGridColumns.length).fill(200));
3360
+ columnList.indexOfLastPinnedColumn = enabledRows.length - 1;
3361
+ columnList.maxRowLevel = enabledRows.length;
3362
+ this._ownersMap.set(DEFAULT_OWNER, columnList);
3363
+ }
3364
+ preparePivotGridColumns(keys, columnGroupParent) {
3365
+ if (keys.length === 0) {
3366
+ return;
3367
+ }
3368
+ let startIndex = 0;
3369
+ const key = keys[0];
3370
+ const records = this.flatRecords.map(r => r.data);
3371
+ const groupedRecords = records.reduce((hash, obj) => (Object.assign(Object.assign({}, hash), { [obj[key.name]]: (hash[obj[key.name]] || []).concat(obj) })), {});
3372
+ if (columnGroupParent) {
3373
+ const mapKeys = [...this.pivotGridKeyValueMap.keys()];
3374
+ const mapValues = [...this.pivotGridKeyValueMap.values()];
3375
+ for (const k of Object.keys(groupedRecords)) {
3376
+ groupedRecords[k] = groupedRecords[k].filter(row => mapKeys.every(mk => Object.keys(row).includes(mk))
3377
+ && mapValues.every(mv => Object.values(row).includes(mv)));
3378
+ if (groupedRecords[k].length === 0) {
3379
+ delete groupedRecords[k];
3380
+ }
3381
+ }
3382
+ }
3383
+ for (const k of Object.keys(groupedRecords)) {
3384
+ const rowSpan = groupedRecords[k].length;
3385
+ const rowDimensionColumn = {
3386
+ rowSpan,
3387
+ field: k,
3388
+ header: k,
3389
+ startIndex,
3390
+ skip: false,
3391
+ pinnedIndex: 0,
3392
+ level: key.level,
3393
+ dataType: 'string',
3394
+ headerType: groupedRecords[k].length > 1 ? HeaderType.MultiRowHeader : HeaderType.RowHeader,
3395
+ };
3396
+ if (columnGroupParent) {
3397
+ rowDimensionColumn.columnGroupParent = columnGroupParent;
3398
+ }
3399
+ else {
3400
+ rowDimensionColumn.columnGroup = k;
3401
+ }
3402
+ this.pivotGridColumns.push(rowDimensionColumn);
3403
+ if (keys.length > 1) {
3404
+ this.pivotGridKeyValueMap.set(key.name, k);
3405
+ const newKeys = keys.filter(kdd => kdd !== key);
3406
+ this.preparePivotGridColumns(newKeys, k);
3407
+ this.pivotGridKeyValueMap.delete(key.name);
3408
+ }
3409
+ startIndex += rowSpan;
3410
+ }
3411
+ }
3290
3412
  resetDefaults() {
3291
3413
  this._sort = null;
3292
3414
  this.flatRecords = [];
@@ -3751,7 +3873,7 @@ class ExcelStrings {
3751
3873
  }
3752
3874
  static getStyles() {
3753
3875
  return ExcelStrings.XML_STRING +
3754
- '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"><fonts count="2" x14ac:knownFonts="1"><font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font><font><sz val="11"/><color rgb="FFB7B7B7"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts><fills count="3"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill><fill><patternFill patternType="solid"><fgColor rgb="FF0D1822"/><bgColor indexed="64"/></patternFill></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="4"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/> <xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/> <xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/><extLst><ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/></ext><ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/></ext></extLst></styleSheet>';
3876
+ '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac x16r2" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:x16r2="http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"><fonts count="2" x14ac:knownFonts="1"><font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font><font><sz val="11"/><color rgb="FFB7B7B7"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts><fills count="3"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill><fill><patternFill patternType="solid"><fgColor rgb="FF0D1822"/><bgColor indexed="64"/></patternFill></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="5"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/><xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/><xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0"/><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment horizontal="center" vertical="center"/></xf></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/><extLst><ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/></ext><ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/></ext></extLst></styleSheet>';
3755
3877
  }
3756
3878
  static getWorkbook(worksheetName) {
3757
3879
  return ExcelStrings.XML_STRING + `<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/><workbookPr filterPrivacy="1" defaultThemeVersion="164011"/><bookViews><workbookView xWindow="0" yWindow="0" windowWidth="22260" windowHeight="12645"/></bookViews><sheets><sheet name="${worksheetName}" sheetId="1" r:id="rId1"/></sheets><calcPr calcId="162913"/><extLst><ext uri="{140A7094-0E35-4892-8432-C4D2E57EDEB5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"><x15:workbookPr chartTrackingRefBase="1"/></ext></extLst></workbook>`;
@@ -3834,7 +3956,7 @@ ExcelStrings.SHARED_STRING_RELATIONSHIP = '<Relationship Id="rId4" Type="http://
3834
3956
  */
3835
3957
  class RootRelsFile {
3836
3958
  writeElement(folder) {
3837
- folder.file('.rels', ExcelStrings.getRels());
3959
+ folder['.rels'] = strToU8(ExcelStrings.getRels());
3838
3960
  }
3839
3961
  }
3840
3962
  /**
@@ -3842,7 +3964,7 @@ class RootRelsFile {
3842
3964
  */
3843
3965
  class AppFile {
3844
3966
  writeElement(folder, worksheetData) {
3845
- folder.file('app.xml', ExcelStrings.getApp(worksheetData.options.worksheetName));
3967
+ folder['app.xml'] = strToU8(ExcelStrings.getApp(worksheetData.options.worksheetName));
3846
3968
  }
3847
3969
  }
3848
3970
  /**
@@ -3850,7 +3972,7 @@ class AppFile {
3850
3972
  */
3851
3973
  class CoreFile {
3852
3974
  writeElement(folder) {
3853
- folder.file('core.xml', ExcelStrings.getCore());
3975
+ folder['core.xml'] = strToU8(ExcelStrings.getCore());
3854
3976
  }
3855
3977
  }
3856
3978
  /**
@@ -3859,7 +3981,7 @@ class CoreFile {
3859
3981
  class WorkbookRelsFile {
3860
3982
  writeElement(folder, worksheetData) {
3861
3983
  const hasSharedStrings = !worksheetData.isEmpty || worksheetData.options.alwaysExportHeaders;
3862
- folder.file('workbook.xml.rels', ExcelStrings.getWorkbookRels(hasSharedStrings));
3984
+ folder['workbook.xml.rels'] = strToU8(ExcelStrings.getWorkbookRels(hasSharedStrings));
3863
3985
  }
3864
3986
  }
3865
3987
  /**
@@ -3867,7 +3989,7 @@ class WorkbookRelsFile {
3867
3989
  */
3868
3990
  class ThemeFile {
3869
3991
  writeElement(folder) {
3870
- folder.file('theme1.xml', ExcelStrings.getTheme());
3992
+ folder['theme1.xml'] = strToU8(ExcelStrings.getTheme());
3871
3993
  }
3872
3994
  }
3873
3995
  /**
@@ -3876,12 +3998,14 @@ class ThemeFile {
3876
3998
  class WorksheetFile {
3877
3999
  constructor() {
3878
4000
  this.maxOutlineLevel = 0;
4001
+ this.sheetData = '';
3879
4002
  this.dimension = '';
3880
4003
  this.freezePane = '';
3881
4004
  this.rowHeight = '';
3882
4005
  this.mergeCellStr = '';
3883
4006
  this.mergeCellsCounter = 0;
3884
4007
  this.rowIndex = 0;
4008
+ this.pivotGridRowHeadersMap = new Map();
3885
4009
  }
3886
4010
  writeElement() { }
3887
4011
  writeElementAsync(folder, worksheetData) {
@@ -3890,70 +4014,57 @@ class WorksheetFile {
3890
4014
  this.prepareDataAsync(worksheetData, (cols, rows) => {
3891
4015
  const hasTable = (!worksheetData.isEmpty || worksheetData.options.alwaysExportHeaders)
3892
4016
  && worksheetData.options.exportAsTable;
3893
- folder.file('sheet1.xml', ExcelStrings.getSheetXML(this.dimension, this.freezePane, cols, rows, hasTable, this.maxOutlineLevel, worksheetData.isHierarchical));
4017
+ folder['sheet1.xml'] = strToU8(ExcelStrings.getSheetXML(this.dimension, this.freezePane, cols, rows, hasTable, this.maxOutlineLevel, worksheetData.isHierarchical));
3894
4018
  resolve();
3895
4019
  });
3896
4020
  });
3897
4021
  });
3898
4022
  }
3899
4023
  prepareDataAsync(worksheetData, done) {
3900
- let sheetData = '';
4024
+ var _a;
4025
+ this.sheetData = '';
3901
4026
  let cols = '';
3902
4027
  const dictionary = worksheetData.dataDictionary;
3903
4028
  this.rowIndex = 0;
3904
4029
  if (worksheetData.isEmpty && (!worksheetData.options.alwaysExportHeaders || worksheetData.owner.columns.length === 0)) {
3905
- sheetData += '<sheetData/>';
4030
+ this.sheetData += '<sheetData/>';
3906
4031
  this.dimension = 'A1';
3907
- done('', sheetData);
4032
+ done('', this.sheetData);
3908
4033
  }
3909
4034
  else {
3910
4035
  const owner = worksheetData.owner;
3911
4036
  const isHierarchicalGrid = worksheetData.isHierarchical;
3912
4037
  const hasMultiColumnHeader = worksheetData.hasMultiColumnHeader;
4038
+ const hasMultiRowHeader = worksheetData.hasMultiRowHeader;
3913
4039
  const hasUserSetIndex = owner.columns.some(col => col.exportIndex !== undefined);
3914
4040
  const height = worksheetData.options.rowHeight;
3915
- const rowStyle = isHierarchicalGrid ? ' s="3"' : '';
3916
4041
  this.rowHeight = height ? ` ht="${height}" customHeight="1"` : '';
3917
- sheetData += `<sheetData>`;
4042
+ this.sheetData += `<sheetData>`;
4043
+ let headersForLevel = [];
4044
+ for (let i = 0; i <= owner.maxRowLevel; i++) {
4045
+ headersForLevel = owner.columns.filter(c => c.level === i && c.rowSpan > 0 && !c.skip);
4046
+ this.printHeaders(worksheetData, headersForLevel, i, true);
4047
+ this.rowIndex++;
4048
+ }
4049
+ this.rowIndex = 0;
3918
4050
  for (let i = 0; i <= owner.maxLevel; i++) {
3919
4051
  this.rowIndex++;
3920
- sheetData += `<row r="${this.rowIndex}"${this.rowHeight}>`;
3921
- const headersForLevel = hasMultiColumnHeader ?
3922
- owner.columns
4052
+ const pivotGridColumns = (_a = this.pivotGridRowHeadersMap.get(this.rowIndex)) !== null && _a !== void 0 ? _a : "";
4053
+ this.sheetData += `<row r="${this.rowIndex}"${this.rowHeight}>${pivotGridColumns}`;
4054
+ const allowedColumns = owner.columns.filter(c => c.headerType !== HeaderType.RowHeader && c.headerType !== HeaderType.MultiRowHeader);
4055
+ headersForLevel = hasMultiColumnHeader ?
4056
+ allowedColumns
3923
4057
  .filter(c => (c.level < i &&
3924
4058
  c.headerType !== HeaderType.MultiColumnHeader || c.level === i) && c.columnSpan > 0 && !c.skip)
3925
4059
  .sort((a, b) => a.startIndex - b.startIndex)
3926
4060
  .sort((a, b) => a.pinnedIndex - b.pinnedIndex) :
3927
4061
  hasUserSetIndex ?
3928
- owner.columns.filter(c => !c.skip) :
3929
- owner.columns.filter(c => !c.skip)
4062
+ allowedColumns.filter(c => !c.skip) :
4063
+ allowedColumns.filter(c => !c.skip)
3930
4064
  .sort((a, b) => a.startIndex - b.startIndex)
3931
4065
  .sort((a, b) => a.pinnedIndex - b.pinnedIndex);
3932
- let startValue = 0;
3933
- for (const currentCol of headersForLevel) {
3934
- if (currentCol.level === i) {
3935
- let columnCoordinate;
3936
- columnCoordinate = ExcelStrings.getExcelColumn(startValue) + this.rowIndex;
3937
- const columnValue = dictionary.saveValue(currentCol.header, true);
3938
- sheetData += `<c r="${columnCoordinate}"${rowStyle} t="s"><v>${columnValue}</v></c>`;
3939
- if (i !== owner.maxLevel) {
3940
- this.mergeCellsCounter++;
3941
- this.mergeCellStr += ` <mergeCell ref="${columnCoordinate}:`;
3942
- if (currentCol.headerType === HeaderType.ColumnHeader) {
3943
- columnCoordinate = ExcelStrings.getExcelColumn(startValue) + (owner.maxLevel + 1);
3944
- }
3945
- else {
3946
- for (let k = 1; k < currentCol.columnSpan; k++) {
3947
- columnCoordinate = ExcelStrings.getExcelColumn(startValue + k) + this.rowIndex;
3948
- sheetData += `<c r="${columnCoordinate}"${rowStyle} />`;
3949
- }
3950
- }
3951
- this.mergeCellStr += `${columnCoordinate}" />`;
3952
- }
3953
- }
3954
- startValue += currentCol.columnSpan;
3955
- }
3956
- sheetData += `</row>`;
4066
+ this.printHeaders(worksheetData, headersForLevel, i, false);
4067
+ this.sheetData += `</row>`;
3957
4068
  }
3958
4069
  const multiColumnHeaderLevel = worksheetData.options.ignoreMultiColumnHeaders ? 0 : owner.maxLevel;
3959
4070
  const freezeHeaders = worksheetData.options.freezeHeaders ? 2 + multiColumnHeaderLevel : 1;
@@ -4006,12 +4117,12 @@ class WorksheetFile {
4006
4117
  }
4007
4118
  }
4008
4119
  this.processDataRecordsAsync(worksheetData, (rows) => {
4009
- sheetData += rows;
4010
- sheetData += '</sheetData>';
4011
- if (hasMultiColumnHeader && this.mergeCellsCounter > 0) {
4012
- sheetData += `<mergeCells count="${this.mergeCellsCounter}">${this.mergeCellStr}</mergeCells>`;
4120
+ this.sheetData += rows;
4121
+ this.sheetData += '</sheetData>';
4122
+ if ((hasMultiColumnHeader || hasMultiRowHeader) && this.mergeCellsCounter > 0) {
4123
+ this.sheetData += `<mergeCells count="${this.mergeCellsCounter}">${this.mergeCellStr}</mergeCells>`;
4013
4124
  }
4014
- done(cols, sheetData);
4125
+ done(cols, this.sheetData);
4015
4126
  });
4016
4127
  }
4017
4128
  }
@@ -4030,7 +4141,7 @@ class WorksheetFile {
4030
4141
  }
4031
4142
  else {
4032
4143
  recordHeaders = worksheetData.owner.columns
4033
- .filter(c => c.headerType !== HeaderType.MultiColumnHeader && !c.skip)
4144
+ .filter(c => c.headerType !== HeaderType.MultiColumnHeader && c.headerType !== HeaderType.MultiRowHeader && c.headerType !== HeaderType.RowHeader && !c.skip)
4034
4145
  .sort((a, b) => a.startIndex - b.startIndex)
4035
4146
  .sort((a, b) => a.pinnedIndex - b.pinnedIndex)
4036
4147
  .map(c => c.field);
@@ -4097,6 +4208,7 @@ class WorksheetFile {
4097
4208
  }
4098
4209
  }
4099
4210
  processRow(worksheetData, i, headersForLevel, isHierarchicalGrid) {
4211
+ var _a;
4100
4212
  const record = worksheetData.data[i];
4101
4213
  const rowData = new Array(worksheetData.columnCount + 2);
4102
4214
  const rowLevel = record.level;
@@ -4104,11 +4216,12 @@ class WorksheetFile {
4104
4216
  this.maxOutlineLevel = this.maxOutlineLevel < rowLevel ? rowLevel : this.maxOutlineLevel;
4105
4217
  const sHidden = record.hidden ? ` hidden="1"` : '';
4106
4218
  this.rowIndex++;
4219
+ const pivotGridColumns = (_a = this.pivotGridRowHeadersMap.get(this.rowIndex)) !== null && _a !== void 0 ? _a : "";
4107
4220
  rowData[0] =
4108
- `<row r="${this.rowIndex}"${this.rowHeight}${outlineLevel}${sHidden}>`;
4221
+ `<row r="${this.rowIndex}"${this.rowHeight}${outlineLevel}${sHidden}>${pivotGridColumns}`;
4109
4222
  const keys = worksheetData.isSpecialData ? [record.data] : headersForLevel;
4110
4223
  for (let j = 0; j < keys.length; j++) {
4111
- const col = j + (isHierarchicalGrid ? rowLevel : 0);
4224
+ const col = j + (isHierarchicalGrid ? rowLevel : worksheetData.isPivotGrid ? worksheetData.owner.maxRowLevel : 0);
4112
4225
  const cellData = this.getCellData(worksheetData, i, col, keys[j]);
4113
4226
  rowData[j + 1] = cellData;
4114
4227
  }
@@ -4141,6 +4254,75 @@ class WorksheetFile {
4141
4254
  return `<c r="${columnName}"${type}${format}><v>${value}</v></c>`;
4142
4255
  }
4143
4256
  }
4257
+ printHeaders(worksheetData, headersForLevel, i, isVertical) {
4258
+ var _a, _b;
4259
+ let startValue = 0;
4260
+ let str = '';
4261
+ const isHierarchicalGrid = worksheetData.isHierarchical;
4262
+ let rowStyle = isHierarchicalGrid ? ' s="3"' : '';
4263
+ const dictionary = worksheetData.dataDictionary;
4264
+ const owner = worksheetData.owner;
4265
+ const maxLevel = isVertical
4266
+ ? owner.maxRowLevel
4267
+ : owner.maxLevel;
4268
+ for (const currentCol of headersForLevel) {
4269
+ const spanLength = isVertical ? currentCol.rowSpan : currentCol.columnSpan;
4270
+ if (currentCol.level === i) {
4271
+ let columnCoordinate;
4272
+ const column = isVertical
4273
+ ? this.rowIndex
4274
+ : startValue + ((_a = owner.maxRowLevel) !== null && _a !== void 0 ? _a : 0);
4275
+ const rowCoordinate = isVertical
4276
+ ? startValue + owner.maxLevel + 2
4277
+ : this.rowIndex;
4278
+ const columnValue = dictionary.saveValue(currentCol.header, true);
4279
+ columnCoordinate = ExcelStrings.getExcelColumn(column) + rowCoordinate;
4280
+ rowStyle = isVertical && currentCol.rowSpan > 1 ? ' s="4"' : rowStyle;
4281
+ str = `<c r="${columnCoordinate}"${rowStyle} t="s"><v>${columnValue}</v></c>`;
4282
+ if (isVertical) {
4283
+ if (this.pivotGridRowHeadersMap.has(rowCoordinate)) {
4284
+ this.pivotGridRowHeadersMap.set(rowCoordinate, this.pivotGridRowHeadersMap.get(rowCoordinate) + str);
4285
+ }
4286
+ else {
4287
+ this.pivotGridRowHeadersMap.set(rowCoordinate, str);
4288
+ }
4289
+ }
4290
+ else {
4291
+ this.sheetData += str;
4292
+ }
4293
+ if (i !== maxLevel) {
4294
+ this.mergeCellsCounter++;
4295
+ this.mergeCellStr += ` <mergeCell ref="${columnCoordinate}:`;
4296
+ if (currentCol.headerType === HeaderType.ColumnHeader) {
4297
+ const col = isVertical
4298
+ ? maxLevel
4299
+ : startValue + ((_b = owner.maxRowLevel) !== null && _b !== void 0 ? _b : 0);
4300
+ const row = isVertical
4301
+ ? rowCoordinate
4302
+ : owner.maxLevel + 1;
4303
+ columnCoordinate = ExcelStrings.getExcelColumn(col) + row;
4304
+ }
4305
+ else {
4306
+ for (let k = 1; k < spanLength; k++) {
4307
+ const col = isVertical
4308
+ ? column
4309
+ : column + k;
4310
+ const row = isVertical
4311
+ ? rowCoordinate + k
4312
+ : this.rowIndex;
4313
+ columnCoordinate = ExcelStrings.getExcelColumn(col) + row;
4314
+ str = `<c r="${columnCoordinate}"${rowStyle} />`;
4315
+ isVertical
4316
+ ? this.pivotGridRowHeadersMap.set(row, str)
4317
+ : this.sheetData += str;
4318
+ }
4319
+ }
4320
+ this.mergeCellStr += `${columnCoordinate}" />`;
4321
+ }
4322
+ }
4323
+ startValue += spanLength;
4324
+ }
4325
+ }
4144
4326
  }
4145
4327
  WorksheetFile.MIN_WIDTH = 8.43;
4146
4328
  /**
@@ -4148,7 +4330,7 @@ WorksheetFile.MIN_WIDTH = 8.43;
4148
4330
  */
4149
4331
  class StyleFile {
4150
4332
  writeElement(folder) {
4151
- folder.file('styles.xml', ExcelStrings.getStyles());
4333
+ folder['styles.xml'] = strToU8(ExcelStrings.getStyles());
4152
4334
  }
4153
4335
  }
4154
4336
  /**
@@ -4156,7 +4338,7 @@ class StyleFile {
4156
4338
  */
4157
4339
  class WorkbookFile {
4158
4340
  writeElement(folder, worksheetData) {
4159
- folder.file('workbook.xml', ExcelStrings.getWorkbook(worksheetData.options.worksheetName));
4341
+ folder['workbook.xml'] = strToU8(ExcelStrings.getWorkbook(worksheetData.options.worksheetName));
4160
4342
  }
4161
4343
  }
4162
4344
  /**
@@ -4165,7 +4347,7 @@ class WorkbookFile {
4165
4347
  class ContentTypesFile {
4166
4348
  writeElement(folder, worksheetData) {
4167
4349
  const hasSharedStrings = !worksheetData.isEmpty || worksheetData.options.alwaysExportHeaders;
4168
- folder.file('[Content_Types].xml', ExcelStrings.getContentTypesXML(hasSharedStrings, worksheetData.options.exportAsTable));
4350
+ folder['[Content_Types].xml'] = strToU8(ExcelStrings.getContentTypesXML(hasSharedStrings, worksheetData.options.exportAsTable));
4169
4351
  }
4170
4352
  }
4171
4353
  /**
@@ -4179,7 +4361,7 @@ class SharedStringsFile {
4179
4361
  for (const value of sortedValues) {
4180
4362
  sharedStrings[dict.getSanitizedValue(value)] = '<si><t>' + value + '</t></si>';
4181
4363
  }
4182
- folder.file('sharedStrings.xml', ExcelStrings.getSharedStringXML(dict.stringsCount, sortedValues.length, sharedStrings.join('')));
4364
+ folder['sharedStrings.xml'] = strToU8(ExcelStrings.getSharedStringXML(dict.stringsCount, sortedValues.length, sharedStrings.join('')));
4183
4365
  }
4184
4366
  }
4185
4367
  /**
@@ -4214,7 +4396,7 @@ class TablesFile {
4214
4396
  const dir = sortingExpression.dir - 1;
4215
4397
  sortString = `<sortState ref="A2:${lastColumn}"><sortCondition descending="${dir}" ref="${sc}1:${sc}15"/></sortState>`;
4216
4398
  }
4217
- folder.file('table1.xml', ExcelStrings.getTablesXML(autoFilterDimension, tableDimension, tableColumns, sortString));
4399
+ folder['table1.xml'] = strToU8(ExcelStrings.getTablesXML(autoFilterDimension, tableDimension, tableColumns, sortString));
4218
4400
  }
4219
4401
  }
4220
4402
  /**
@@ -4222,7 +4404,7 @@ class TablesFile {
4222
4404
  */
4223
4405
  class WorksheetRelsFile {
4224
4406
  writeElement(folder) {
4225
- folder.file('sheet1.xml.rels', ExcelStrings.getWorksheetRels());
4407
+ folder['sheet1.xml.rels'] = strToU8(ExcelStrings.getWorksheetRels());
4226
4408
  }
4227
4409
  }
4228
4410
 
@@ -4540,20 +4722,29 @@ class WorksheetData {
4540
4722
  get hasMultiColumnHeader() {
4541
4723
  return this._hasMultiColumnHeader;
4542
4724
  }
4725
+ get hasMultiRowHeader() {
4726
+ return this._hasMultiRowHeader;
4727
+ }
4543
4728
  get isHierarchical() {
4544
4729
  return this._isHierarchical;
4545
4730
  }
4731
+ get isPivotGrid() {
4732
+ return this._isPivotGrid;
4733
+ }
4546
4734
  get multiColumnHeaderRows() {
4547
4735
  return !this.options.ignoreMultiColumnHeaders ? Array.from(this.owners.values()).map(c => c.maxLevel).reduce((a, b) => a + b) : 0;
4548
4736
  }
4549
4737
  initializeData() {
4550
- var _a;
4738
+ var _a, _b;
4551
4739
  this._dataDictionary = new WorksheetDataDictionary(this.columnCount, this.options.columnWidth, this.columnWidths);
4552
4740
  this._hasMultiColumnHeader = Array.from(this.owners.values())
4553
4741
  .some(o => o.columns.some(col => !col.skip && col.headerType === HeaderType.MultiColumnHeader));
4742
+ this._hasMultiRowHeader = Array.from(this.owners.values())
4743
+ .some(o => o.columns.some(col => !col.skip && col.headerType === HeaderType.MultiRowHeader));
4554
4744
  this._isHierarchical = ((_a = this.data[0]) === null || _a === void 0 ? void 0 : _a.type) === ExportRecordType.HierarchicalGridRecord
4555
4745
  || !(typeof (Array.from(this.owners.keys())[0]) === 'string');
4556
- if (this._isHierarchical || (this._hasMultiColumnHeader && !this.options.ignoreMultiColumnHeaders)) {
4746
+ this._isPivotGrid = ((_b = this.data[0]) === null || _b === void 0 ? void 0 : _b.type) === ExportRecordType.PivotGridRecord;
4747
+ if (this._isHierarchical || this._isPivotGrid || (this._hasMultiColumnHeader && !this.options.ignoreMultiColumnHeaders)) {
4557
4748
  this.options.exportAsTable = false;
4558
4749
  }
4559
4750
  if (!this._data || this._data.length === 0) {
@@ -4605,20 +4796,20 @@ class IgxExcelExporterService extends IgxBaseExporter {
4605
4796
  */
4606
4797
  this.exportEnded = new EventEmitter();
4607
4798
  }
4608
- static populateFolderAsync(folder, zip, worksheetData) {
4799
+ static populateZipFileConfig(fileStructure, folder, worksheetData) {
4609
4800
  return __awaiter(this, void 0, void 0, function* () {
4610
4801
  for (const childFolder of folder.childFolders(worksheetData)) {
4611
4802
  const folderInstance = ExcelElementsFactory.getExcelFolder(childFolder);
4612
- const zipFolder = zip.folder(folderInstance.folderName);
4613
- yield IgxExcelExporterService.populateFolderAsync(folderInstance, zipFolder, worksheetData);
4803
+ const childStructure = fileStructure[folderInstance.folderName] = {};
4804
+ yield IgxExcelExporterService.populateZipFileConfig(childStructure, folderInstance, worksheetData);
4614
4805
  }
4615
4806
  for (const childFile of folder.childFiles(worksheetData)) {
4616
4807
  const fileInstance = ExcelElementsFactory.getExcelFile(childFile);
4617
4808
  if (fileInstance instanceof WorksheetFile) {
4618
- yield fileInstance.writeElementAsync(zip, worksheetData);
4809
+ yield fileInstance.writeElementAsync(fileStructure, worksheetData);
4619
4810
  }
4620
4811
  else {
4621
- fileInstance.writeElement(zip, worksheetData);
4812
+ fileInstance.writeElement(fileStructure, worksheetData);
4622
4813
  }
4623
4814
  }
4624
4815
  });
@@ -4626,6 +4817,7 @@ class IgxExcelExporterService extends IgxBaseExporter {
4626
4817
  exportDataImplementation(data, options, done) {
4627
4818
  const firstDataElement = data[0];
4628
4819
  const isHierarchicalGrid = (firstDataElement === null || firstDataElement === void 0 ? void 0 : firstDataElement.type) === ExportRecordType.HierarchicalGridRecord;
4820
+ const isPivotGrid = (firstDataElement === null || firstDataElement === void 0 ? void 0 : firstDataElement.type) === ExportRecordType.PivotGridRecord;
4629
4821
  let rootKeys;
4630
4822
  let columnCount;
4631
4823
  let columnWidths;
@@ -4659,7 +4851,7 @@ class IgxExcelExporterService extends IgxBaseExporter {
4659
4851
  const columns = defaultOwner.columns.filter(col => !col.skip && col.headerType === HeaderType.ColumnHeader);
4660
4852
  columnWidths = defaultOwner.columnWidths;
4661
4853
  indexOfLastPinnedColumn = defaultOwner.indexOfLastPinnedColumn;
4662
- columnCount = columns.length;
4854
+ columnCount = isPivotGrid ? columns.length + this.pivotGridFilterFieldsCount : columns.length;
4663
4855
  rootKeys = columns.map(c => c.field);
4664
4856
  }
4665
4857
  }
@@ -4670,25 +4862,24 @@ class IgxExcelExporterService extends IgxBaseExporter {
4670
4862
  columnCount = defaultOwner.columns.filter(col => !col.skip && col.headerType === HeaderType.ColumnHeader).length;
4671
4863
  }
4672
4864
  const worksheetData = new WorksheetData(data, options, this._sort, columnCount, rootKeys, indexOfLastPinnedColumn, columnWidths, defaultOwner, this._ownersMap);
4673
- this._xlsx = typeof JSZip.default === 'function' ? new JSZip.default() : new JSZip();
4674
4865
  const rootFolder = ExcelElementsFactory.getExcelFolder(ExcelFolderTypes.RootExcelFolder);
4675
- IgxExcelExporterService.populateFolderAsync(rootFolder, this._xlsx, worksheetData)
4866
+ const fileData = {};
4867
+ IgxExcelExporterService.populateZipFileConfig(fileData, rootFolder, worksheetData)
4676
4868
  .then(() => {
4677
- this._xlsx.generateAsync(IgxExcelExporterService.ZIP_OPTIONS).then((result) => {
4869
+ zip(fileData, (_, result) => {
4678
4870
  this.saveFile(result, options.fileName);
4679
- this.exportEnded.emit({ xlsx: this._xlsx });
4871
+ this.exportEnded.emit({ xlsx: fileData });
4680
4872
  done();
4681
4873
  });
4682
4874
  });
4683
4875
  }
4684
4876
  saveFile(data, fileName) {
4685
- const blob = new Blob([ExportUtilities.stringToArrayBuffer(atob(data))], {
4877
+ const blob = new Blob([data], {
4686
4878
  type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
4687
4879
  });
4688
4880
  ExportUtilities.saveBlobToFile(blob, fileName);
4689
4881
  }
4690
4882
  }
4691
- IgxExcelExporterService.ZIP_OPTIONS = { compression: 'DEFLATE', type: 'base64' };
4692
4883
  IgxExcelExporterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: IgxExcelExporterService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
4693
4884
  IgxExcelExporterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: IgxExcelExporterService, providedIn: 'root' });
4694
4885
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: IgxExcelExporterService, decorators: [{