Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 5413e94

Browse files
committed
feat(exports): add auto-detect and Excel custom cell (column) styling
- add `excelExportOptions` and `groupTotalsExcelExportOptions` to allow for custom cell width & styling of every column.
1 parent 2646527 commit 5413e94

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/app/examples/grid-clientside.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class GridClientSideComponent implements OnInit {
123123
filterable: true, filter: { model: Filters.compoundInputNumber }
124124
},
125125
{
126-
id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, sortable: true, minWidth: 75, exportWithFormatter: false,
126+
id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, sortable: true, minWidth: 75,
127127
type: FieldType.date, filterable: true, filter: { model: Filters.compoundDate }
128128
},
129129
{

src/app/examples/grid-grouping.component.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,34 @@ export class GridGroupingComponent implements OnInit {
107107
},
108108
{
109109
id: 'cost', name: 'Cost', field: 'cost',
110-
minWidth: 70,
111-
width: 100,
112-
filterable: true,
110+
minWidth: 70, width: 80,
111+
sortable: true, filterable: true,
113112
filter: { model: Filters.compoundInputNumber },
114113
type: FieldType.number,
115-
sortable: true,
116-
exportWithFormatter: true,
117-
formatter: Formatters.dollar,
118-
groupTotalsFormatter: GroupTotalFormatters.sumTotalsDollar,
119-
params: { groupFormatterPrefix: '<b>Total</b>: ' /*, groupFormatterSuffix: ' USD'*/ }
114+
formatter: Formatters.currency,
115+
groupTotalsFormatter: GroupTotalFormatters.sumTotalsCurrency,
116+
params: { displayNegativeNumberWithParentheses: true, currencyPrefix: '€', groupFormatterCurrencyPrefix: '€', minDecimal: 2, maxDecimal: 4, groupFormatterPrefix: '<b>Total</b>: ' },
117+
excelExportOptions: {
118+
style: {
119+
font: { outline: true, italic: true },
120+
format: '€0.00##;[Red](€0.00##)',
121+
},
122+
width: 18
123+
},
124+
groupTotalsExcelExportOptions: {
125+
style: {
126+
alignment: { horizontal: 'center' },
127+
font: { bold: true, color: 'FF005289', underline: 'single', fontName: 'Consolas', size: 10 },
128+
fill: { type: 'pattern', patternType: 'solid', fgColor: 'FFE6F2F6' },
129+
border: {
130+
top: { color: 'FFa500ff', style: 'thick', },
131+
left: { color: 'FFa500ff', style: 'medium', },
132+
right: { color: 'FFa500ff', style: 'dotted', },
133+
bottom: { color: 'FFa500ff', style: 'double', },
134+
},
135+
format: '"Total: "€0.00##;[Red]"Total: "(€0.00##)'
136+
},
137+
},
120138
},
121139
{
122140
id: 'effort-driven', name: 'Effort Driven',
@@ -169,6 +187,7 @@ export class GridGroupingComponent implements OnInit {
169187
const randomMonth = Math.floor(Math.random() * 11);
170188
const randomDay = Math.floor((Math.random() * 29));
171189
const randomPercent = Math.round(Math.random() * 100);
190+
const randomCost = (i % 33 === 0) ? null : Math.round(Math.random() * 10000) / 100;
172191

173192
this.dataset[i] = {
174193
id: 'id_' + i,
@@ -179,7 +198,7 @@ export class GridGroupingComponent implements OnInit {
179198
percentCompleteNumber: randomPercent,
180199
start: new Date(randomYear, randomMonth, randomDay),
181200
finish: new Date(randomYear, (randomMonth + 1), randomDay),
182-
cost: (i % 33 === 0) ? null : Math.round(Math.random() * 10000) / 100,
201+
cost: i % 3 ? randomCost : randomCost !== null ? -randomCost : null,
183202
effortDriven: (i % 5 === 0)
184203
};
185204
}

0 commit comments

Comments
 (0)