nillud-data-table 1.4.2 → 1.4.4

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.
@@ -1,6 +1,193 @@
1
- import {
2
- ExportExcel_default
3
- } from "../../chunk-YP52DDKU.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
37
+
38
+ // components/export/export-excel/exportUtils.ts
39
+ var generateExcelColumns = (columns, exportCustomColumns) => {
40
+ let excelColumns = columns.filter((column) => column.title !== "").map((column) => ({
41
+ title: column.title,
42
+ key: column.field,
43
+ width: 20
44
+ }));
45
+ if (exportCustomColumns) {
46
+ exportCustomColumns.forEach((custom) => {
47
+ excelColumns = excelColumns.map(
48
+ (col) => col.key === custom.key ? __spreadValues(__spreadValues({}, col), custom) : col
49
+ );
50
+ });
51
+ }
52
+ return excelColumns;
53
+ };
54
+ var applyHeaderStyles = (row, columnCount) => {
55
+ row.height = 40;
56
+ row.font = { size: 12, bold: true };
57
+ row.alignment = { vertical: "middle", horizontal: "center" };
58
+ for (let i = 1; i <= columnCount; i++) {
59
+ const cell = row.getCell(i);
60
+ cell.alignment = { wrapText: true, vertical: "middle", horizontal: "center" };
61
+ cell.border = {
62
+ top: { style: "thin" },
63
+ left: { style: "thin" },
64
+ bottom: { style: "thin" },
65
+ right: { style: "thin" }
66
+ };
67
+ }
68
+ };
69
+ var applyRowStyles = (row, columnCount, height = 40, columns) => {
70
+ row.height = height;
71
+ row.font = { size: 12 };
72
+ row.alignment = { vertical: "middle", horizontal: "center" };
73
+ for (let i = 1; i <= columnCount; i++) {
74
+ const cell = row.getCell(i);
75
+ const column = columns[i - 1];
76
+ cell.alignment = {
77
+ wrapText: true,
78
+ vertical: column.cellAlignment ? column.cellAlignment.vertical : "middle",
79
+ horizontal: column.cellAlignment ? column.cellAlignment.horizontal : "center"
80
+ };
81
+ cell.border = {
82
+ top: { style: "thin" },
83
+ left: { style: "thin" },
84
+ bottom: { style: "thin" },
85
+ right: { style: "thin" }
86
+ };
87
+ }
88
+ };
89
+ var generateExcelDataRows = (columns, data, exportCustomColumns) => {
90
+ return data.map((element, rowIndex) => {
91
+ return columns.map((col, colIndex) => {
92
+ const isAutoinc = col.autoinc;
93
+ if (isAutoinc) return rowIndex + 1;
94
+ const value = element[col.field];
95
+ const customCol = exportCustomColumns == null ? void 0 : exportCustomColumns.find((custom) => custom.key === col.field);
96
+ if (customCol == null ? void 0 : customCol.exportCustomCell) {
97
+ return customCol.exportCustomCell(String(value != null ? value : ""), element);
98
+ }
99
+ if (typeof col.exportCustomCell !== "undefined") {
100
+ return col.exportCustomCell(String(value != null ? value : ""), element);
101
+ }
102
+ return value != null ? value : "";
103
+ });
104
+ });
105
+ };
106
+ var setColumnAutoWidths = (sheet) => {
107
+ var _a;
108
+ (_a = sheet.columns) == null ? void 0 : _a.forEach((column) => {
109
+ var _a2;
110
+ let maxLength = 10;
111
+ (_a2 = column.eachCell) == null ? void 0 : _a2.call(column, { includeEmpty: true }, (cell) => {
112
+ const cellValue = cell.value ? String(cell.value) : "";
113
+ maxLength = Math.max(maxLength, cellValue.length + 5);
114
+ });
115
+ column.width = maxLength;
116
+ });
117
+ };
118
+
119
+ // components/export/export-excel/ExportExcel.tsx
120
+ import ExcelJS from "exceljs";
121
+ import { jsx } from "react/jsx-runtime";
122
+ var ExportExcel = ({ columns, excelData, tableRef, titleFile, title, text, exportCustomColumns, customHeight }) => {
123
+ const exportExcel = () => __async(null, null, function* () {
124
+ const tableData = excelData || tableRef.current.getData();
125
+ const workbook = new ExcelJS.Workbook();
126
+ const sheet = workbook.addWorksheet(titleFile, {
127
+ pageSetup: {
128
+ fitToPage: true,
129
+ fitToHeight: 2,
130
+ fitToWidth: 1,
131
+ orientation: "landscape"
132
+ },
133
+ headerFooter: {
134
+ oddFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N",
135
+ evenFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N"
136
+ }
137
+ });
138
+ sheet.properties.defaultRowHeight = 20;
139
+ let tableHeaderRow = 1;
140
+ if (title) {
141
+ sheet.getCell("A1").value = title;
142
+ sheet.getRow(1).height = 25;
143
+ sheet.getRow(1).alignment = { vertical: "middle" };
144
+ sheet.getCell("A1").font = {
145
+ size: 18,
146
+ bold: true
147
+ };
148
+ tableHeaderRow++;
149
+ }
150
+ if (text) {
151
+ sheet.getCell("A2").value = text;
152
+ sheet.getRow(2).height = 15;
153
+ sheet.getRow(2).alignment = { vertical: "middle" };
154
+ sheet.getCell("A2").font = {
155
+ size: 12
156
+ };
157
+ tableHeaderRow++;
158
+ }
159
+ if (title || text) tableHeaderRow++;
160
+ const excelColumns = generateExcelColumns(columns, exportCustomColumns);
161
+ sheet.columns = excelColumns;
162
+ const headerRow = sheet.getRow(tableHeaderRow);
163
+ headerRow.values = excelColumns.map((col) => col.title);
164
+ applyHeaderStyles(headerRow, sheet.columns.length);
165
+ const dataRows = generateExcelDataRows(columns, tableData);
166
+ dataRows.forEach((data) => {
167
+ const row = sheet.addRow(data);
168
+ applyRowStyles(row, sheet.columns.length, customHeight, columns);
169
+ });
170
+ setColumnAutoWidths(sheet);
171
+ if (tableData.length > 15) {
172
+ sheet.pageSetup.fitToHeight = Math.floor(tableData.length / 15);
173
+ } else {
174
+ sheet.pageSetup.fitToHeight = 1;
175
+ }
176
+ workbook.xlsx.writeBuffer().then((data) => {
177
+ const blob = new Blob([data], {
178
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
179
+ });
180
+ const url = window.URL.createObjectURL(blob);
181
+ const anchor = document.createElement("a");
182
+ anchor.href = url;
183
+ anchor.download = `${titleFile}.xlsx`;
184
+ anchor.click();
185
+ window.URL.revokeObjectURL(url);
186
+ });
187
+ });
188
+ return /* @__PURE__ */ jsx("button", { className: `ndt-buttonExport ndt-Excel`, onClick: exportExcel, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Excel" });
189
+ };
190
+ var ExportExcel_default = ExportExcel;
4
191
  export {
5
192
  ExportExcel_default as ExportExcel
6
193
  };
@@ -1,6 +1,117 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+
22
+ // components/export/export-word/ExportHelpers.ts
23
+ function prepareExportRows(columns, data) {
24
+ return data.map(
25
+ (row) => columns.map((col) => {
26
+ const value = row[col.field];
27
+ return typeof col.exportCustomCell !== "undefined" ? col.exportCustomCell(String(value), row) : String(value != null ? value : "");
28
+ })
29
+ );
30
+ }
31
+ function prepareExportHeaders(columns) {
32
+ return columns.map((col) => col.title);
33
+ }
34
+
35
+ // components/export/export-word/ExportWord.tsx
1
36
  import {
2
- ExportWord_default
3
- } from "../../chunk-MLSI37NJ.js";
37
+ AlignmentType,
38
+ Document,
39
+ Packer,
40
+ PageOrientation,
41
+ Paragraph,
42
+ Table,
43
+ TableCell,
44
+ TableRow,
45
+ TextRun,
46
+ VerticalAlign,
47
+ WidthType
48
+ } from "docx";
49
+ import { saveAs } from "file-saver";
50
+ import { jsx } from "react/jsx-runtime";
51
+ var WordExport = ({
52
+ wordData,
53
+ columns,
54
+ title,
55
+ options = {
56
+ fontSize: 20,
57
+ boldHeaders: false,
58
+ autoLandscape: false,
59
+ maxColumnsBeforeLandscape: 5
60
+ }
61
+ }) => {
62
+ const createNewWord = () => __async(null, null, function* () {
63
+ const {
64
+ fontSize = 0,
65
+ boldHeaders = true,
66
+ autoLandscape = true,
67
+ maxColumnsBeforeLandscape = 5
68
+ } = options;
69
+ const isLandscape = autoLandscape && columns.length > maxColumnsBeforeLandscape;
70
+ const headerCells = prepareExportHeaders(columns).map((header) => new TableCell({
71
+ children: [new Paragraph({
72
+ children: [new TextRun({
73
+ text: header,
74
+ size: fontSize,
75
+ bold: boldHeaders
76
+ })],
77
+ alignment: AlignmentType.CENTER
78
+ })],
79
+ verticalAlign: VerticalAlign.CENTER
80
+ }));
81
+ const tableHeaderRow = new TableRow({ children: headerCells });
82
+ const rows = prepareExportRows(columns, wordData).map((cells) => {
83
+ const rowCells = cells.map(
84
+ (value) => new TableCell({
85
+ children: [new Paragraph({
86
+ children: [new TextRun({
87
+ text: value,
88
+ size: fontSize
89
+ })],
90
+ alignment: AlignmentType.CENTER
91
+ })],
92
+ verticalAlign: VerticalAlign.CENTER
93
+ })
94
+ );
95
+ return new TableRow({ children: rowCells });
96
+ });
97
+ const table = new Table({
98
+ rows: [tableHeaderRow, ...rows],
99
+ width: { size: 11e3, type: WidthType.DXA },
100
+ indent: { size: -1e3, type: WidthType.DXA }
101
+ });
102
+ const doc = new Document({
103
+ sections: [{
104
+ children: [table, new Paragraph({ text: "" })],
105
+ properties: isLandscape ? { page: { size: { orientation: PageOrientation.LANDSCAPE } } } : {}
106
+ }]
107
+ });
108
+ Packer.toBlob(doc).then((blob) => {
109
+ saveAs(blob, `${title}.docx`);
110
+ });
111
+ });
112
+ return /* @__PURE__ */ jsx("button", { className: `ndt-buttonExport ndt-Word}`, onClick: createNewWord, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Word" });
113
+ };
114
+ var ExportWord_default = WordExport;
4
115
  export {
5
116
  ExportWord_default as WordExport
6
117
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  import React, { ReactElement } from 'react';
2
- export { WordExport } from './export/export-word/index.js';
3
- export { ExportExcel } from './export/export-excel/index.js';
4
- import 'react/jsx-runtime';
5
- import 'exceljs';
6
2
 
7
3
  type TableElement = {
8
4
  [key: string]: string | number;
package/dist/index.js CHANGED
@@ -1,10 +1,3 @@
1
- import {
2
- ExportExcel_default
3
- } from "./chunk-YP52DDKU.js";
4
- import {
5
- ExportWord_default
6
- } from "./chunk-MLSI37NJ.js";
7
-
8
1
  // components/data-table/DataTable.tsx
9
2
  import { useImperativeHandle, useEffect as useEffect2, useState, useCallback, useMemo as useMemo4, forwardRef } from "react";
10
3
 
@@ -681,7 +674,5 @@ var DataTable = forwardRef(({
681
674
  DataTable.displayName = "DataTable";
682
675
  var DataTable_default = DataTable;
683
676
  export {
684
- DataTable_default as DataTable,
685
- ExportExcel_default as ExportExcel,
686
- ExportWord_default as WordExport
677
+ DataTable_default as DataTable
687
678
  };
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "nillud-data-table",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "style": "./dist/styles.css",
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "dist/export/export-excel",
12
+ "dist/export/export-word"
11
13
  ],
12
14
  "exports": {
13
15
  ".": {
14
16
  "import": "./dist/index.js",
15
- "require": "./dist/index.js",
16
17
  "types": "./dist/index.d.ts"
17
18
  },
18
19
  "./types": "./dist/index.d.ts",
@@ -29,11 +30,11 @@
29
30
  }
30
31
  },
31
32
  "peerDependencies": {
33
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
34
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
32
35
  "docx": "^8.1.2",
33
36
  "exceljs": "^4.3.0",
34
- "file-saver": "^2.0.5",
35
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
36
- "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
37
+ "file-saver": "^2.0.5"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@types/file-saver": "^2.0.7",
@@ -43,6 +44,7 @@
43
44
  "tsup": "^8.4.0",
44
45
  "typescript": "^5.8.3"
45
46
  },
47
+ "optionalDependencies": {},
46
48
  "scripts": {
47
49
  "build": "tsup && npm run build:styles",
48
50
  "build:styles": "node build-styles.js"
@@ -1,97 +0,0 @@
1
- // components/export/export-word/ExportHelpers.ts
2
- function prepareExportRows(columns, data) {
3
- return data.map(
4
- (row) => columns.map((col) => {
5
- const value = row[col.field];
6
- return typeof col.exportCustomCell !== "undefined" ? col.exportCustomCell(String(value), row) : String(value != null ? value : "");
7
- })
8
- );
9
- }
10
- function prepareExportHeaders(columns) {
11
- return columns.map((col) => col.title);
12
- }
13
-
14
- // components/export/export-word/ExportWord.tsx
15
- import {
16
- AlignmentType,
17
- Document,
18
- Packer,
19
- PageOrientation,
20
- Paragraph,
21
- Table,
22
- TableCell,
23
- TableRow,
24
- TextRun,
25
- VerticalAlign,
26
- WidthType
27
- } from "docx";
28
- import { saveAs } from "file-saver";
29
- import { jsx } from "react/jsx-runtime";
30
- var WordExport = ({
31
- wordData,
32
- columns,
33
- title,
34
- options = {
35
- fontSize: 20,
36
- boldHeaders: false,
37
- autoLandscape: false,
38
- maxColumnsBeforeLandscape: 5
39
- }
40
- }) => {
41
- const createNewWord = async () => {
42
- const {
43
- fontSize = 0,
44
- boldHeaders = true,
45
- autoLandscape = true,
46
- maxColumnsBeforeLandscape = 5
47
- } = options;
48
- const isLandscape = autoLandscape && columns.length > maxColumnsBeforeLandscape;
49
- const headerCells = prepareExportHeaders(columns).map((header) => new TableCell({
50
- children: [new Paragraph({
51
- children: [new TextRun({
52
- text: header,
53
- size: fontSize,
54
- bold: boldHeaders
55
- })],
56
- alignment: AlignmentType.CENTER
57
- })],
58
- verticalAlign: VerticalAlign.CENTER
59
- }));
60
- const tableHeaderRow = new TableRow({ children: headerCells });
61
- const rows = prepareExportRows(columns, wordData).map((cells) => {
62
- const rowCells = cells.map(
63
- (value) => new TableCell({
64
- children: [new Paragraph({
65
- children: [new TextRun({
66
- text: value,
67
- size: fontSize
68
- })],
69
- alignment: AlignmentType.CENTER
70
- })],
71
- verticalAlign: VerticalAlign.CENTER
72
- })
73
- );
74
- return new TableRow({ children: rowCells });
75
- });
76
- const table = new Table({
77
- rows: [tableHeaderRow, ...rows],
78
- width: { size: 11e3, type: WidthType.DXA },
79
- indent: { size: -1e3, type: WidthType.DXA }
80
- });
81
- const doc = new Document({
82
- sections: [{
83
- children: [table, new Paragraph({ text: "" })],
84
- properties: isLandscape ? { page: { size: { orientation: PageOrientation.LANDSCAPE } } } : {}
85
- }]
86
- });
87
- Packer.toBlob(doc).then((blob) => {
88
- saveAs(blob, `${title}.docx`);
89
- });
90
- };
91
- return /* @__PURE__ */ jsx("button", { className: `ndt-buttonExport ndt-Word}`, onClick: createNewWord, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Word" });
92
- };
93
- var ExportWord_default = WordExport;
94
-
95
- export {
96
- ExportWord_default
97
- };
@@ -1,157 +0,0 @@
1
- // components/export/export-excel/exportUtils.ts
2
- var generateExcelColumns = (columns, exportCustomColumns) => {
3
- let excelColumns = columns.filter((column) => column.title !== "").map((column) => ({
4
- title: column.title,
5
- key: column.field,
6
- width: 20
7
- }));
8
- if (exportCustomColumns) {
9
- exportCustomColumns.forEach((custom) => {
10
- excelColumns = excelColumns.map(
11
- (col) => col.key === custom.key ? { ...col, ...custom } : col
12
- );
13
- });
14
- }
15
- return excelColumns;
16
- };
17
- var applyHeaderStyles = (row, columnCount) => {
18
- row.height = 40;
19
- row.font = { size: 12, bold: true };
20
- row.alignment = { vertical: "middle", horizontal: "center" };
21
- for (let i = 1; i <= columnCount; i++) {
22
- const cell = row.getCell(i);
23
- cell.alignment = { wrapText: true, vertical: "middle", horizontal: "center" };
24
- cell.border = {
25
- top: { style: "thin" },
26
- left: { style: "thin" },
27
- bottom: { style: "thin" },
28
- right: { style: "thin" }
29
- };
30
- }
31
- };
32
- var applyRowStyles = (row, columnCount, height = 40, columns) => {
33
- row.height = height;
34
- row.font = { size: 12 };
35
- row.alignment = { vertical: "middle", horizontal: "center" };
36
- for (let i = 1; i <= columnCount; i++) {
37
- const cell = row.getCell(i);
38
- const column = columns[i - 1];
39
- cell.alignment = {
40
- wrapText: true,
41
- vertical: column.cellAlignment ? column.cellAlignment.vertical : "middle",
42
- horizontal: column.cellAlignment ? column.cellAlignment.horizontal : "center"
43
- };
44
- cell.border = {
45
- top: { style: "thin" },
46
- left: { style: "thin" },
47
- bottom: { style: "thin" },
48
- right: { style: "thin" }
49
- };
50
- }
51
- };
52
- var generateExcelDataRows = (columns, data, exportCustomColumns) => {
53
- return data.map((element, rowIndex) => {
54
- return columns.map((col, colIndex) => {
55
- const isAutoinc = col.autoinc;
56
- if (isAutoinc) return rowIndex + 1;
57
- const value = element[col.field];
58
- const customCol = exportCustomColumns == null ? void 0 : exportCustomColumns.find((custom) => custom.key === col.field);
59
- if (customCol == null ? void 0 : customCol.exportCustomCell) {
60
- return customCol.exportCustomCell(String(value != null ? value : ""), element);
61
- }
62
- if (typeof col.exportCustomCell !== "undefined") {
63
- return col.exportCustomCell(String(value != null ? value : ""), element);
64
- }
65
- return value != null ? value : "";
66
- });
67
- });
68
- };
69
- var setColumnAutoWidths = (sheet) => {
70
- var _a;
71
- (_a = sheet.columns) == null ? void 0 : _a.forEach((column) => {
72
- var _a2;
73
- let maxLength = 10;
74
- (_a2 = column.eachCell) == null ? void 0 : _a2.call(column, { includeEmpty: true }, (cell) => {
75
- const cellValue = cell.value ? String(cell.value) : "";
76
- maxLength = Math.max(maxLength, cellValue.length + 5);
77
- });
78
- column.width = maxLength;
79
- });
80
- };
81
-
82
- // components/export/export-excel/ExportExcel.tsx
83
- import ExcelJS from "exceljs";
84
- import { jsx } from "react/jsx-runtime";
85
- var ExportExcel = ({ columns, excelData, tableRef, titleFile, title, text, exportCustomColumns, customHeight }) => {
86
- const exportExcel = async () => {
87
- const tableData = excelData || tableRef.current.getData();
88
- const workbook = new ExcelJS.Workbook();
89
- const sheet = workbook.addWorksheet(titleFile, {
90
- pageSetup: {
91
- fitToPage: true,
92
- fitToHeight: 2,
93
- fitToWidth: 1,
94
- orientation: "landscape"
95
- },
96
- headerFooter: {
97
- oddFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N",
98
- evenFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N"
99
- }
100
- });
101
- sheet.properties.defaultRowHeight = 20;
102
- let tableHeaderRow = 1;
103
- if (title) {
104
- sheet.getCell("A1").value = title;
105
- sheet.getRow(1).height = 25;
106
- sheet.getRow(1).alignment = { vertical: "middle" };
107
- sheet.getCell("A1").font = {
108
- size: 18,
109
- bold: true
110
- };
111
- tableHeaderRow++;
112
- }
113
- if (text) {
114
- sheet.getCell("A2").value = text;
115
- sheet.getRow(2).height = 15;
116
- sheet.getRow(2).alignment = { vertical: "middle" };
117
- sheet.getCell("A2").font = {
118
- size: 12
119
- };
120
- tableHeaderRow++;
121
- }
122
- if (title || text) tableHeaderRow++;
123
- const excelColumns = generateExcelColumns(columns, exportCustomColumns);
124
- sheet.columns = excelColumns;
125
- const headerRow = sheet.getRow(tableHeaderRow);
126
- headerRow.values = excelColumns.map((col) => col.title);
127
- applyHeaderStyles(headerRow, sheet.columns.length);
128
- const dataRows = generateExcelDataRows(columns, tableData);
129
- dataRows.forEach((data) => {
130
- const row = sheet.addRow(data);
131
- applyRowStyles(row, sheet.columns.length, customHeight, columns);
132
- });
133
- setColumnAutoWidths(sheet);
134
- if (tableData.length > 15) {
135
- sheet.pageSetup.fitToHeight = Math.floor(tableData.length / 15);
136
- } else {
137
- sheet.pageSetup.fitToHeight = 1;
138
- }
139
- workbook.xlsx.writeBuffer().then((data) => {
140
- const blob = new Blob([data], {
141
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
142
- });
143
- const url = window.URL.createObjectURL(blob);
144
- const anchor = document.createElement("a");
145
- anchor.href = url;
146
- anchor.download = `${titleFile}.xlsx`;
147
- anchor.click();
148
- window.URL.revokeObjectURL(url);
149
- });
150
- };
151
- return /* @__PURE__ */ jsx("button", { className: `ndt-buttonExport ndt-Excel`, onClick: exportExcel, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Excel" });
152
- };
153
- var ExportExcel_default = ExportExcel;
154
-
155
- export {
156
- ExportExcel_default
157
- };