igniteui-angular 14.2.0-alpha.4 → 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.
- package/esm2020/lib/services/excel/excel-exporter.mjs +3 -2
- package/esm2020/lib/services/excel/excel-files.mjs +101 -44
- package/esm2020/lib/services/excel/excel-strings.mjs +2 -2
- package/esm2020/lib/services/excel/worksheet-data.mjs +11 -2
- package/esm2020/lib/services/exporter-common/base-export-service.mjs +127 -5
- package/fesm2015/igniteui-angular.mjs +241 -49
- package/fesm2015/igniteui-angular.mjs.map +1 -1
- package/fesm2020/igniteui-angular.mjs +237 -48
- package/fesm2020/igniteui-angular.mjs.map +1 -1
- package/lib/services/excel/excel-files.d.ts +3 -0
- package/lib/services/excel/worksheet-data.d.ts +4 -0
- package/lib/services/exporter-common/base-export-service.d.ts +22 -4
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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="
|
|
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>`;
|
|
@@ -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) {
|
|
@@ -3897,63 +4021,50 @@ class WorksheetFile {
|
|
|
3897
4021
|
});
|
|
3898
4022
|
}
|
|
3899
4023
|
prepareDataAsync(worksheetData, done) {
|
|
3900
|
-
|
|
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
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
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
|
-
|
|
3929
|
-
|
|
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
|
-
|
|
3933
|
-
|
|
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
|
/**
|
|
@@ -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
|
-
|
|
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) {
|
|
@@ -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
|
}
|