@slickgrid-universal/excel-export 5.0.0 → 5.1.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.
@@ -19,14 +19,14 @@ export declare class ExcelExportService implements ExternalResource, BaseExcelEx
19
19
  protected _workbook: Workbook;
20
20
  protected _regularCellExcelFormats: {
21
21
  [fieldId: string]: {
22
- stylesheetFormatterId?: number;
22
+ excelFormatId?: number;
23
23
  getDataValueParser: GetDataValueCallback;
24
24
  };
25
25
  };
26
26
  protected _groupTotalExcelFormats: {
27
27
  [fieldId: string]: {
28
28
  groupType: string;
29
- stylesheetFormatter?: ExcelFormatter;
29
+ excelFormat?: ExcelFormatter;
30
30
  getGroupTotalParser?: GetGroupTotalValueCallback;
31
31
  };
32
32
  };
@@ -42,13 +42,13 @@ export declare class ExcelExportService implements ExternalResource, BaseExcelEx
42
42
  get groupTotalExcelFormats(): {
43
43
  [fieldId: string]: {
44
44
  groupType: string;
45
- stylesheetFormatter?: ExcelFormatter | undefined;
45
+ excelFormat?: ExcelFormatter | undefined;
46
46
  getGroupTotalParser?: GetGroupTotalValueCallback | undefined;
47
47
  };
48
48
  };
49
49
  get regularCellExcelFormats(): {
50
50
  [fieldId: string]: {
51
- stylesheetFormatterId?: number | undefined;
51
+ excelFormatId?: number | undefined;
52
52
  getDataValueParser: GetDataValueCallback;
53
53
  };
54
54
  };
@@ -111,7 +111,7 @@ export declare class ExcelExportService implements ExternalResource, BaseExcelEx
111
111
  * @param {Number} row - row index
112
112
  * @param {Object} itemObj - item datacontext object
113
113
  */
114
- protected readRegularRowData(columns: Column[], row: number, itemObj: any): string[];
114
+ protected readRegularRowData(columns: Column[], row: number, itemObj: any, dataRowIdx: number): string[];
115
115
  /**
116
116
  * Get the grouped title(s) and its group title formatter, for example if we grouped by salesRep, the returned result would be:: 'Sales Rep: John Dow (2 items)'
117
117
  * @param itemObj
@@ -122,6 +122,6 @@ export declare class ExcelExportService implements ExternalResource, BaseExcelEx
122
122
  * For example if we grouped by "salesRep" and we have a Sum Aggregator on "sales", then the returned output would be:: ["Sum 123$"]
123
123
  * @param itemObj
124
124
  */
125
- protected readGroupedTotalRows(columns: Column[], itemObj: any): Array<ExcelColumnMetadata | string | number>;
125
+ protected readGroupedTotalRows(columns: Column[], itemObj: any, dataRowIdx: number): Array<ExcelColumnMetadata | string | number>;
126
126
  }
127
127
  //# sourceMappingURL=excelExport.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"excelExport.service.d.ts","sourceRoot":"","sources":["../../src/excelExport.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,QAAQ,EACR,KAAK,SAAS,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,kBAAkB,IAAI,sBAAsB,EAC5C,iBAAiB,EACjB,gBAAgB,EAEhB,oBAAoB,EACpB,0BAA0B,EAC1B,UAAU,EACV,YAAY,EACZ,MAAM,EACN,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAKL,QAAQ,EAIT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,cAAc,CAAC;AAOtB,qBAAa,kBAAmB,YAAW,gBAAgB,EAAE,sBAAsB;IACjF,SAAS,CAAC,WAAW,WAAiB;IACtC,SAAS,CAAC,KAAK,EAAG,SAAS,CAAC;IAC5B,SAAS,CAAC,QAAQ,EAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,qBAAqB,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IACtD,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,YAAY,CAAC,CAAM;IACnD,SAAS,CAAC,wBAAwB,UAAS;IAC3C,SAAS,CAAC,gBAAgB,UAAS;IACnC,SAAS,CAAC,mBAAmB,EAA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}
@@ -8,11 +8,14 @@ export declare const getExcelNumberCallback: GetDataValueCallback;
8
8
  /** Parse a number which the user might have provided formatter options (for example a user might have provided { decimalSeparator: ',', thousandSeparator: ' '}) */
9
9
  export declare function parseNumberWithFormatterOptions(value: any, column: Column, gridOptions: GridOption): any;
10
10
  /** use different Excel Stylesheet Format as per the Field Type */
11
- export declare function useCellFormatByFieldType(stylesheet: StyleSheet, stylesheetFormatters: any, columnDef: Column, grid: SlickGrid, autoDetect?: boolean): {
12
- stylesheetFormatterId: number | undefined;
11
+ export declare function useCellFormatByFieldType(stylesheet: StyleSheet, excelFormats: any, columnDef: Column, grid: SlickGrid, autoDetect?: boolean): {
12
+ excelFormatId: number | undefined;
13
13
  getDataValueParser: GetDataValueCallback;
14
14
  };
15
- export declare function getGroupTotalValue(totals: any, columnDef: Column, groupType: string): any;
15
+ export declare function getGroupTotalValue(totals: any, args: {
16
+ columnDef: Column;
17
+ groupType: string;
18
+ }): any;
16
19
  /** Get numeric formatter options when defined or use default values (minDecimal, maxDecimal, thousandSeparator, decimalSeparator, wrapNegativeNumber) */
17
20
  export declare function getNumericFormatterOptions(columnDef: Column, grid: SlickGrid, formatterType: FormatterType): {
18
21
  minDecimal: any;
@@ -26,8 +29,8 @@ export declare function getNumericFormatterOptions(columnDef: Column, grid: Slic
26
29
  numberSuffix: string;
27
30
  };
28
31
  export declare function getFormatterNumericDataType(formatter?: Formatter): "currency" | "decimal" | "percent";
29
- export declare function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, stylesheetFormatters: any, columnDef: Column, grid: SlickGrid, formatterType: FormatterType): {
30
- stylesheetFormatter: ExcelFormatter;
32
+ export declare function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, excelFormats: any, columnDef: Column, grid: SlickGrid, formatterType: FormatterType): {
33
+ excelFormat: ExcelFormatter;
31
34
  groupType: string;
32
35
  };
33
36
  //# sourceMappingURL=excelUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"excelUtils.d.ts","sourceRoot":"","sources":["../../src/excelUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,SAAS,EACV,MAAM,6BAA6B,CAAC;AAYrC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;CAAE,CAAC;AAGtD,eAAO,MAAM,6BAA6B,EAAE,oBAAqC,CAAC;AAClF,eAAO,MAAM,sBAAsB,EAAE,oBAGnC,CAAC;AAEH,oKAAoK;AACpK,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,OAUlG;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,UAAO;;;EAUhJ;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAEnF;AAED,yJAAyJ;AACzJ,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa;;;;;;;;;;EA6C1G;AAED,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE,SAAS,sCAwBhE;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa;;;EAkFlK"}
1
+ {"version":3,"file":"excelUtils.d.ts","sourceRoot":"","sources":["../../src/excelUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,SAAS,EACV,MAAM,6BAA6B,CAAC;AAYrC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;CAAE,CAAC;AAGtD,eAAO,MAAM,6BAA6B,EAAE,oBAI3C,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,oBAGnC,CAAC;AAEH,oKAAoK;AACpK,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,OAUlG;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,UAAO;;;EAUxI;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;CAAE,OAE9F;AAED,yJAAyJ;AACzJ,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa;;;;;;;;;;EA6C1G;AAED,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE,SAAS,sCAwBhE;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa;;;EAkF1J"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slickgrid-universal/excel-export",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "Excel Export (xls/xlsx) Service.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -38,7 +38,7 @@
38
38
  "not dead"
39
39
  ],
40
40
  "dependencies": {
41
- "@slickgrid-universal/common": "~5.0.0",
41
+ "@slickgrid-universal/common": "~5.1.0",
42
42
  "@slickgrid-universal/utils": "~5.0.0",
43
43
  "excel-builder-vanilla": "^3.0.1"
44
44
  },
@@ -46,5 +46,5 @@
46
46
  "type": "ko_fi",
47
47
  "url": "https://ko-fi.com/ghiscoding"
48
48
  },
49
- "gitHead": "526fc83e33b1e6ea236082b1b4cb50be623f4569"
49
+ "gitHead": "dec8be36272c9111cd708a1836e1697ac81be323"
50
50
  }
@@ -11,8 +11,8 @@ import type {
11
11
  ContainerService,
12
12
  ExcelExportService as BaseExcelExportService,
13
13
  ExcelExportOption,
14
+ ExcelGroupValueParserArgs,
14
15
  ExternalResource,
15
-
16
16
  GetDataValueCallback,
17
17
  GetGroupTotalValueCallback,
18
18
  GridOption,
@@ -64,8 +64,8 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
64
64
  protected _workbook!: Workbook;
65
65
 
66
66
  // references of each detected cell and/or group total formats
67
- protected _regularCellExcelFormats: { [fieldId: string]: { stylesheetFormatterId?: number; getDataValueParser: GetDataValueCallback; }; } = {};
68
- protected _groupTotalExcelFormats: { [fieldId: string]: { groupType: string; stylesheetFormatter?: ExcelFormatter; getGroupTotalParser?: GetGroupTotalValueCallback; }; } = {};
67
+ protected _regularCellExcelFormats: { [fieldId: string]: { excelFormatId?: number; getDataValueParser: GetDataValueCallback; }; } = {};
68
+ protected _groupTotalExcelFormats: { [fieldId: string]: { groupType: string; excelFormat?: ExcelFormatter; getGroupTotalParser?: GetGroupTotalValueCallback; }; } = {};
69
69
 
70
70
  /** ExcelExportService class name which is use to find service instance in the external registered services */
71
71
  readonly className = 'ExcelExportService';
@@ -155,15 +155,15 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
155
155
  this._stylesheet = this._workbook.getStyleSheet();
156
156
 
157
157
  // create some common default Excel formatters that will be used
158
- const boldFormatter = this._stylesheet.createFormat({ font: { bold: true } });
159
- const stringFormatter = this._stylesheet.createFormat({ format: '@' });
160
- const numberFormatter = this._stylesheet.createFormat({ format: '0' });
158
+ const boldFormat = this._stylesheet.createFormat({ font: { bold: true } });
159
+ const stringFormat = this._stylesheet.createFormat({ format: '@' });
160
+ const numberFormat = this._stylesheet.createFormat({ format: '0' });
161
161
  this._stylesheetFormats = {
162
- boldFormatter,
163
- numberFormatter,
164
- stringFormatter,
162
+ boldFormat,
163
+ numberFormat,
164
+ stringFormat,
165
165
  };
166
- this._sheet.setColumnFormats([boldFormatter]);
166
+ this._sheet.setColumnFormats([boldFormat]);
167
167
 
168
168
  // get the CSV output from the grid data
169
169
  const dataOutput = this.getDataOutput();
@@ -238,7 +238,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
238
238
  const outputData: Array<string[] | ExcelColumnMetadata[]> = [];
239
239
  const gridExportOptions = this._gridOptions?.excelExportOptions;
240
240
  const columnHeaderStyle = gridExportOptions?.columnHeaderStyle;
241
- let columnHeaderStyleId = this._stylesheetFormats.boldFormatter.id;
241
+ let columnHeaderStyleId = this._stylesheetFormats.boldFormat.id;
242
242
  if (columnHeaderStyle) {
243
243
  columnHeaderStyleId = this._stylesheet.createFormat(columnHeaderStyle).id;
244
244
  }
@@ -435,13 +435,13 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
435
435
  // Normal row (not grouped by anything) would have an ID which was predefined in the Grid Columns definition
436
436
  if (itemObj[this._datasetIdPropName] !== null && itemObj[this._datasetIdPropName] !== undefined) {
437
437
  // get regular row item data
438
- originalDaraArray.push(this.readRegularRowData(columns, rowNumber, itemObj));
438
+ originalDaraArray.push(this.readRegularRowData(columns, rowNumber, itemObj, rowNumber));
439
439
  } else if (this._hasGroupedItems && itemObj.__groupTotals === undefined) {
440
440
  // get the group row
441
441
  originalDaraArray.push([this.readGroupedRowTitle(itemObj)]);
442
442
  } else if (itemObj.__groupTotals) {
443
443
  // else if the row is a Group By and we have agreggators, then a property of '__groupTotals' would exist under that object
444
- originalDaraArray.push(this.readGroupedTotalRows(columns, itemObj));
444
+ originalDaraArray.push(this.readGroupedTotalRows(columns, itemObj, rowNumber));
445
445
  }
446
446
  }
447
447
  }
@@ -454,7 +454,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
454
454
  * @param {Number} row - row index
455
455
  * @param {Object} itemObj - item datacontext object
456
456
  */
457
- protected readRegularRowData(columns: Column[], row: number, itemObj: any): string[] {
457
+ protected readRegularRowData(columns: Column[], row: number, itemObj: any, dataRowIdx: number): string[] {
458
458
  let idx = 0;
459
459
  const rowOutputStrings = [];
460
460
  const columnsLn = columns.length;
@@ -539,7 +539,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
539
539
  const cellStyleFormat = useCellFormatByFieldType(this._stylesheet, this._stylesheetFormats, columnDef, this._grid, autoDetectCellFormat);
540
540
  // user could also override style and/or valueParserCallback
541
541
  if (columnDef.excelExportOptions?.style) {
542
- cellStyleFormat.stylesheetFormatterId = this._stylesheet.createFormat(columnDef.excelExportOptions.style).id;
542
+ cellStyleFormat.excelFormatId = this._stylesheet.createFormat(columnDef.excelExportOptions.style).id;
543
543
  }
544
544
  if (columnDef.excelExportOptions?.valueParserCallback) {
545
545
  cellStyleFormat.getDataValueParser = columnDef.excelExportOptions.valueParserCallback;
@@ -552,8 +552,8 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
552
552
  itemData = stripTags(itemData as string);
553
553
  }
554
554
 
555
- const { stylesheetFormatterId, getDataValueParser } = this._regularCellExcelFormats[columnDef.id];
556
- itemData = getDataValueParser(itemData, columnDef, stylesheetFormatterId, this._stylesheet, this._gridOptions);
555
+ const { excelFormatId, getDataValueParser } = this._regularCellExcelFormats[columnDef.id];
556
+ itemData = getDataValueParser(itemData, { columnDef, excelFormatId, stylesheet: this._stylesheet, gridOptions: this._gridOptions, dataRowIdx, dataContext: itemObj });
557
557
 
558
558
  rowOutputStrings.push(itemData);
559
559
  idx++;
@@ -584,7 +584,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
584
584
  * For example if we grouped by "salesRep" and we have a Sum Aggregator on "sales", then the returned output would be:: ["Sum 123$"]
585
585
  * @param itemObj
586
586
  */
587
- protected readGroupedTotalRows(columns: Column[], itemObj: any): Array<ExcelColumnMetadata | string | number> {
587
+ protected readGroupedTotalRows(columns: Column[], itemObj: any, dataRowIdx: number): Array<ExcelColumnMetadata | string | number> {
588
588
  const groupingAggregatorRowText = this._excelExportOptions.groupingAggregatorRowText || '';
589
589
  const outputStrings: Array<ExcelColumnMetadata | string | number> = [groupingAggregatorRowText];
590
590
 
@@ -607,17 +607,17 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
607
607
  if (!groupCellFormat?.groupType) {
608
608
  groupCellFormat = getExcelFormatFromGridFormatter(this._stylesheet, this._stylesheetFormats, columnDef, this._grid, 'group');
609
609
  if (columnDef.groupTotalsExcelExportOptions?.style) {
610
- groupCellFormat.stylesheetFormatter = this._stylesheet.createFormat(columnDef.groupTotalsExcelExportOptions.style);
610
+ groupCellFormat.excelFormat = this._stylesheet.createFormat(columnDef.groupTotalsExcelExportOptions.style);
611
611
  }
612
612
  this._groupTotalExcelFormats[columnDef.id] = groupCellFormat;
613
613
  }
614
614
 
615
615
  const groupTotalParser = columnDef.groupTotalsExcelExportOptions?.valueParserCallback ?? getGroupTotalValue;
616
616
  if (itemObj[groupCellFormat.groupType]?.[columnDef.field] !== undefined) {
617
- itemData = {
618
- value: groupTotalParser(itemObj, columnDef, groupCellFormat.groupType, this._stylesheet),
619
- metadata: { style: groupCellFormat.stylesheetFormatter?.id }
620
- };
617
+ const groupData = groupTotalParser(itemObj, { columnDef, groupType: groupCellFormat.groupType, excelFormatId: groupCellFormat.excelFormat?.id, stylesheet: this._stylesheet, dataRowIdx } as ExcelGroupValueParserArgs);
618
+ itemData = (typeof groupData === 'object' && groupData.hasOwnProperty('metadata'))
619
+ ? groupData
620
+ : itemData = { value: groupData, metadata: { style: groupCellFormat.excelFormat?.id } };
621
621
  }
622
622
  } else if (columnDef.groupTotalsFormatter) {
623
623
  const totalResult = columnDef.groupTotalsFormatter(itemObj, columnDef, this._grid);
package/src/excelUtils.ts CHANGED
@@ -21,10 +21,14 @@ import { stripTags } from '@slickgrid-universal/utils';
21
21
  export type ExcelFormatter = object & { id: number; };
22
22
 
23
23
  // define all type of potential excel data function callbacks
24
- export const getExcelSameInputDataCallback: GetDataValueCallback = (data) => data;
25
- export const getExcelNumberCallback: GetDataValueCallback = (data, column, excelFormatterId, _excelSheet, gridOptions) => ({
26
- value: typeof data === 'string' && /\d/g.test(data) ? parseNumberWithFormatterOptions(data, column, gridOptions) : data,
27
- metadata: { style: excelFormatterId }
24
+ export const getExcelSameInputDataCallback: GetDataValueCallback = (data, { excelFormatId }) => {
25
+ return excelFormatId !== undefined
26
+ ? { value: data, metadata: { style: excelFormatId } }
27
+ : data;
28
+ };
29
+ export const getExcelNumberCallback: GetDataValueCallback = (data, { columnDef, excelFormatId, gridOptions }) => ({
30
+ value: typeof data === 'string' && /\d/g.test(data) ? parseNumberWithFormatterOptions(data, columnDef, gridOptions) : data,
31
+ metadata: { style: excelFormatId }
28
32
  });
29
33
 
30
34
  /** Parse a number which the user might have provided formatter options (for example a user might have provided { decimalSeparator: ',', thousandSeparator: ' '}) */
@@ -41,20 +45,20 @@ export function parseNumberWithFormatterOptions(value: any, column: Column, grid
41
45
  }
42
46
 
43
47
  /** use different Excel Stylesheet Format as per the Field Type */
44
- export function useCellFormatByFieldType(stylesheet: StyleSheet, stylesheetFormatters: any, columnDef: Column, grid: SlickGrid, autoDetect = true) {
48
+ export function useCellFormatByFieldType(stylesheet: StyleSheet, excelFormats: any, columnDef: Column, grid: SlickGrid, autoDetect = true) {
45
49
  const fieldType = getColumnFieldType(columnDef);
46
- let stylesheetFormatterId: number | undefined;
50
+ let excelFormatId: number | undefined;
47
51
  let callback: GetDataValueCallback = getExcelSameInputDataCallback;
48
52
 
49
53
  if (fieldType === FieldType.number && autoDetect) {
50
- stylesheetFormatterId = getExcelFormatFromGridFormatter(stylesheet, stylesheetFormatters, columnDef, grid, 'cell').stylesheetFormatter.id;
54
+ excelFormatId = getExcelFormatFromGridFormatter(stylesheet, excelFormats, columnDef, grid, 'cell').excelFormat.id;
51
55
  callback = getExcelNumberCallback;
52
56
  }
53
- return { stylesheetFormatterId, getDataValueParser: callback };
57
+ return { excelFormatId, getDataValueParser: callback };
54
58
  }
55
59
 
56
- export function getGroupTotalValue(totals: any, columnDef: Column, groupType: string) {
57
- return totals?.[groupType]?.[columnDef.field] ?? 0;
60
+ export function getGroupTotalValue(totals: any, args: { columnDef: Column, groupType: string; }) {
61
+ return totals?.[args.groupType]?.[args.columnDef.field] ?? 0;
58
62
  }
59
63
 
60
64
  /** Get numeric formatter options when defined or use default values (minDecimal, maxDecimal, thousandSeparator, decimalSeparator, wrapNegativeNumber) */
@@ -131,10 +135,10 @@ export function getFormatterNumericDataType(formatter?: Formatter) {
131
135
  return dataType;
132
136
  }
133
137
 
134
- export function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, stylesheetFormatters: any, columnDef: Column, grid: SlickGrid, formatterType: FormatterType) {
138
+ export function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, excelFormats: any, columnDef: Column, grid: SlickGrid, formatterType: FormatterType) {
135
139
  let format = '';
136
- let groupType = '';
137
- let stylesheetFormatter: undefined | ExcelFormatter;
140
+ let groupType = columnDef.groupTotalsExcelExportOptions?.groupType || '';
141
+ let excelFormat: undefined | ExcelFormatter;
138
142
  const fieldType = getColumnFieldType(columnDef);
139
143
 
140
144
  if (formatterType === 'group') {
@@ -163,7 +167,7 @@ export function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, styleshe
163
167
  groupType = 'sum';
164
168
  break;
165
169
  default:
166
- stylesheetFormatter = stylesheetFormatters.numberFormatter;
170
+ excelFormat = excelFormats.numberFormat;
167
171
  break;
168
172
  }
169
173
  } else {
@@ -174,15 +178,15 @@ export function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, styleshe
174
178
  // when formatter is a Formatter.multiple, we need to loop through each of its formatter to find the best possible Excel format
175
179
  if (Array.isArray(columnDef.params?.formatters)) {
176
180
  for (const formatter of columnDef.params.formatters) {
177
- const { stylesheetFormatter: stylesheetFormatterResult } = getExcelFormatFromGridFormatter(stylesheet, stylesheetFormatters, { ...columnDef, formatter } as Column, grid, formatterType);
178
- if (stylesheetFormatterResult !== stylesheetFormatters.numberFormatter) {
179
- stylesheetFormatter = stylesheetFormatterResult;
181
+ const { excelFormat: excelFormatResult } = getExcelFormatFromGridFormatter(stylesheet, excelFormats, { ...columnDef, formatter } as Column, grid, formatterType);
182
+ if (excelFormatResult !== excelFormats.numberFormat) {
183
+ excelFormat = excelFormatResult;
180
184
  break;
181
185
  }
182
186
  }
183
187
  }
184
- if (!stylesheetFormatter) {
185
- stylesheetFormatter = stylesheetFormatters.numberFormatter;
188
+ if (!excelFormat) {
189
+ excelFormat = excelFormats.numberFormat;
186
190
  }
187
191
  break;
188
192
  case Formatters.currency:
@@ -198,21 +202,21 @@ export function getExcelFormatFromGridFormatter(stylesheet: StyleSheet, styleshe
198
202
  format = createExcelFormatFromGridFormatter(columnDef, grid, 'cell');
199
203
  break;
200
204
  default:
201
- stylesheetFormatter = stylesheetFormatters.numberFormatter;
205
+ excelFormat = excelFormats.numberFormat;
202
206
  break;
203
207
  }
204
208
  break;
205
209
  }
206
210
  }
207
211
 
208
- if (!stylesheetFormatter && (columnDef.formatter || columnDef.groupTotalsFormatter)) {
212
+ if (!excelFormat && (columnDef.formatter || columnDef.groupTotalsFormatter)) {
209
213
  format = createExcelFormatFromGridFormatter(columnDef, grid, formatterType, groupType);
210
- if (!stylesheetFormatters.hasOwnProperty(format)) {
211
- stylesheetFormatters[format] = stylesheet.createFormat({ format }); // save new formatter with its format as a prop key
214
+ if (!excelFormats.hasOwnProperty(format)) {
215
+ excelFormats[format] = stylesheet.createFormat({ format }); // save new formatter with its format as a prop key
212
216
  }
213
- stylesheetFormatter = stylesheetFormatters[format] as ExcelFormatter;
217
+ excelFormat = excelFormats[format] as ExcelFormatter;
214
218
  }
215
- return { stylesheetFormatter: stylesheetFormatter as ExcelFormatter, groupType };
219
+ return { excelFormat: excelFormat as ExcelFormatter, groupType };
216
220
  }
217
221
 
218
222
  // --