@colijnit/corecomponents_v12 256.1.25 → 256.1.27

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.
@@ -10484,7 +10484,55 @@
10484
10484
  this.headerColumnsCopy = this.headerColumns;
10485
10485
  };
10486
10486
  SimpleGridComponent.prototype.exportToExcel = function () {
10487
- this.excelExportService.exportTableToExcel('simple-grid-table', 'ExcelSheet', 'Sheet1');
10487
+ this.isSettingsMenuOpen = false;
10488
+ var exportData = this._filterSelectedOrReturnAll(this.data);
10489
+ var columns = this.headerColumnsCopy.map(function (column) {
10490
+ return ({
10491
+ key: column.field,
10492
+ header: column.headerText
10493
+ });
10494
+ });
10495
+ var headers = columns.map(function (col) { return col.header; });
10496
+ var rows = exportData.map(function (row) { return columns.map(function (col) {
10497
+ var value = row[col.key];
10498
+ if (value instanceof Date) {
10499
+ var formattedDate = value.toISOString().split('T')[0];
10500
+ var _a = __read(formattedDate.split('-'), 3), year = _a[0], month = _a[1], day = _a[2];
10501
+ return day + "-" + month + "-" + year;
10502
+ }
10503
+ else if (typeof value === 'number') {
10504
+ var hasDecimal = function (num) { return !Number.isInteger(num); };
10505
+ return hasDecimal ? value.toFixed(2) : value.toFixed(0);
10506
+ }
10507
+ else if (Array.isArray(value)) {
10508
+ return value.join(', ');
10509
+ }
10510
+ else if (typeof value === 'object' && value !== null) {
10511
+ return JSON.stringify(value);
10512
+ }
10513
+ else {
10514
+ if (!value)
10515
+ return '';
10516
+ if (value.includes('T00:00:00')) {
10517
+ var _b = __read(value.replace('T00:00:00', '').split('-'), 3), year = _b[0], month = _b[1], day = _b[2];
10518
+ return day + "-" + month + "-" + year;
10519
+ }
10520
+ return String(value);
10521
+ }
10522
+ }); });
10523
+ var csvContent = __spreadArray([headers], __read(rows)).map(function (row) { return row.map(function (cell) { return "\"" + cell.replace(/"/g, '""') + "\""; }).join(','); }).join('\r\n');
10524
+ var blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
10525
+ var link = document.createElement('a');
10526
+ var url = URL.createObjectURL(blob);
10527
+ link.href = url;
10528
+ link.setAttribute('download', 'ExcelSheet');
10529
+ document.body.appendChild(link);
10530
+ link.click();
10531
+ document.body.removeChild(link);
10532
+ };
10533
+ SimpleGridComponent.prototype._filterSelectedOrReturnAll = function (items) {
10534
+ var hasSelectedTrue = items.some(function (item) { return item.selected === true; });
10535
+ return hasSelectedTrue ? items.filter(function (item) { return item.selected === true; }) : items;
10488
10536
  };
10489
10537
  SimpleGridComponent.prototype.prepareDataRow = function (row, index) {
10490
10538
  this.isRowDisabled(row, index);