Skip to content

Commit 591d27f

Browse files
Merge branch '18.1.x' into aahmedov/fix-replaceHardcodedStrings-14620-18.1.x
2 parents 8293eb4 + 618b0b4 commit 591d27f

File tree

6 files changed

+626
-10
lines changed

6 files changed

+626
-10
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.interface.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export interface IPivotDimensionStrategy {
5959
export type PivotAggregation = (members: any[], data: any[]) => any;
6060

6161
/* marshalByValue */
62-
/* jsonAPIComplexObject */
6362
/**
6463
* Interface describing a IPivotAggregator class.
6564
* Used for specifying custom aggregator lists.
@@ -85,7 +84,6 @@ export interface IPivotAggregator {
8584
}
8685

8786
/* marshalByValue */
88-
/* jsonAPIComplexObject */
8987
/**
9088
* Configuration of the pivot grid.
9189
*/
@@ -108,7 +106,6 @@ export interface IPivotConfiguration {
108106

109107
/* blazorElement */
110108
/* marshalByValue */
111-
/* jsonAPIComplexObject */
112109
/**
113110
* Configuration of a pivot dimension.
114111
*/
@@ -150,7 +147,6 @@ export interface IPivotDimension {
150147
}
151148

152149
/* marshalByValue */
153-
/* jsonAPIComplexObject */
154150
/**
155151
* Configuration of a pivot value aggregation.
156152
*/

projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {
2020
GridWithThreeLevelsOfMultiColumnHeadersAndTwoRowsExportComponent,
2121
GroupedGridWithSummariesComponent,
2222
GridCurrencySummariesComponent,
23-
GridUserMeetingDataComponent
23+
GridUserMeetingDataComponent,
24+
GridCustomSummaryComponent,
25+
GridCustomSummaryWithNullAndZeroComponent,
26+
GridCustomSummaryWithUndefinedZeroAndValidNumberComponent,
27+
GridCustomSummaryWithUndefinedAndNullComponent,
28+
GridCustomSummaryWithDateComponent
2429
} from '../../test-utils/grid-samples.spec';
2530
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
2631
import { first } from 'rxjs/operators';
@@ -75,7 +80,12 @@ describe('Excel Exporter', () => {
7580
IgxHierarchicalGridSummariesExportComponent,
7681
GroupedGridWithSummariesComponent,
7782
GridCurrencySummariesComponent,
78-
GridUserMeetingDataComponent
83+
GridUserMeetingDataComponent,
84+
GridCustomSummaryComponent,
85+
GridCustomSummaryWithNullAndZeroComponent,
86+
GridCustomSummaryWithUndefinedZeroAndValidNumberComponent,
87+
GridCustomSummaryWithUndefinedAndNullComponent,
88+
GridCustomSummaryWithDateComponent
7989
]
8090
}).compileComponents();
8191
}));
@@ -1355,6 +1365,56 @@ describe('Excel Exporter', () => {
13551365

13561366
await exportAndVerify(grid, options, actualData.exportHierarchicalGridWithSummaries);
13571367
});
1368+
1369+
it('should export grid with custom summaries, only with summary label as string', async () => {
1370+
fix = TestBed.createComponent(GridCustomSummaryComponent);
1371+
fix.detectChanges();
1372+
await wait(300);
1373+
1374+
grid = fix.componentInstance.grid;
1375+
1376+
await exportAndVerify(grid, options, actualData.exportGridWithCustomSummaryOnlyWithSummaryLabel);
1377+
});
1378+
1379+
it('should export grid with custom summaries, with null and zero (as number)', async () => {
1380+
fix = TestBed.createComponent(GridCustomSummaryWithNullAndZeroComponent);
1381+
fix.detectChanges();
1382+
await wait(300);
1383+
1384+
grid = fix.componentInstance.grid;
1385+
1386+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithNullAndZero);
1387+
});
1388+
1389+
it('should export grid with custom summaries, with undefined, zero and positive number (as number)', async () => {
1390+
fix = TestBed.createComponent(GridCustomSummaryWithUndefinedZeroAndValidNumberComponent);
1391+
fix.detectChanges();
1392+
await wait(300);
1393+
1394+
grid = fix.componentInstance.grid;
1395+
1396+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithUndefinedZeroAndValidNumber);
1397+
});
1398+
1399+
it('should export grid with custom summaries, with undefined and null', async () => {
1400+
fix = TestBed.createComponent(GridCustomSummaryWithUndefinedAndNullComponent);
1401+
fix.detectChanges();
1402+
await wait(300);
1403+
1404+
grid = fix.componentInstance.grid;
1405+
1406+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithUndefinedAndNull);
1407+
});
1408+
1409+
it('should export grid with custom summaries, with date', async () => {
1410+
fix = TestBed.createComponent(GridCustomSummaryWithDateComponent);
1411+
fix.detectChanges();
1412+
await wait(300);
1413+
1414+
grid = fix.componentInstance.grid;
1415+
1416+
await exportAndVerify(grid, options, actualData.exportGridCustomSummaryWithDate);
1417+
});
13581418
});
13591419

13601420
describe('', () => {

projects/igniteui-angular/src/lib/services/excel/excel-files.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,34 @@ export class WorksheetFile implements IExcelFile {
457457
summaryFunc = this.getSummaryFunction(cellValue.label, key, dimensionMapKey, level, targetCol);
458458

459459
if (!summaryFunc) {
460-
const cellStr = `${cellValue.label}: ${cellValue.value}`;
461-
const savedValue = dictionary.saveValue(cellStr, false);
462-
return `<c r="${columnName}" t="s" s="1"><v>${savedValue}</v></c>`;
460+
let summaryValue;
461+
462+
const label = cellValue.label?.toString();
463+
const value = cellValue.value?.toString();
464+
465+
if (label && value) {
466+
summaryValue = `${cellValue.label}: ${cellValue.value}`;
467+
} else if (label) {
468+
summaryValue = cellValue.label;
469+
} else if (value) {
470+
summaryValue = cellValue.value;
471+
}
472+
473+
const savedValue = dictionary.saveValue(summaryValue, false);
474+
const isSavedAsString = savedValue !== -1;
475+
const isSavedAsDate = !isSavedAsString && summaryValue instanceof Date;
476+
477+
if (isSavedAsDate) {
478+
const timeZoneOffset = summaryValue.getTimezoneOffset() * 60000;
479+
const isoString = (new Date(summaryValue - timeZoneOffset)).toISOString();
480+
summaryValue = isoString.substring(0, isoString.indexOf('.'));
481+
}
482+
483+
const resolvedValue = isSavedAsString ? savedValue : summaryValue;
484+
const type = isSavedAsString ? `t="s"` : isSavedAsDate ? `t="d"` : '';
485+
const style = isSavedAsDate ? `s="2"` : `s="1"`;
486+
487+
return `<c r="${columnName}" ${type} ${style}><v>${resolvedValue}</v></c>`;
463488
}
464489

465490
return `<c r="${columnName}"><f t="array" ref="${columnName}">${summaryFunc}</f></c>`;
@@ -536,7 +561,7 @@ export class WorksheetFile implements IExcelFile {
536561
let result = '';
537562
const currencyInfo = this.currencyStyleMap.get(col.currencyCode);
538563

539-
switch(type.toLowerCase()) {
564+
switch(type?.toString().toLowerCase()) {
540565
case "count":
541566
return `"Count: "&amp;_xlfn.COUNTIF(${levelDimensions.startCoordinate}:${levelDimensions.endCoordinate}, ${recordLevel})`
542567
case "min":

0 commit comments

Comments
 (0)