nillud-data-table 1.4.3 → 1.4.5

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,156 @@
1
- import {
2
- ExportExcel_default
3
- } from "../../chunk-YP52DDKU.js";
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;
4
154
  export {
5
155
  ExportExcel_default as ExportExcel
6
156
  };
@@ -29,6 +29,6 @@ type ExportWordTypes = {
29
29
  options?: ExportOptions;
30
30
  };
31
31
 
32
- declare const WordExport: ({ wordData, columns, title, options }: ExportWordTypes) => react_jsx_runtime.JSX.Element;
32
+ declare const ExportWord: ({ wordData, columns, title, options }: ExportWordTypes) => react_jsx_runtime.JSX.Element;
33
33
 
34
- export { type ExportWordTypes, WordExport };
34
+ export { type ExportWordTypes, ExportWord as WordExport };
@@ -1,6 +1,96 @@
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/WordExport.tsx
1
15
  import {
2
- ExportWord_default
3
- } from "../../chunk-MLSI37NJ.js";
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 ExportWord = ({
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 WordExport_default = ExportWord;
4
94
  export {
5
- ExportWord_default as WordExport
95
+ WordExport_default as WordExport
6
96
  };
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,51 +1,50 @@
1
- {
2
- "name": "nillud-data-table",
3
- "version": "1.4.3",
4
- "type": "module",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "style": "./dist/styles.css",
9
- "files": [
10
- "dist"
11
- ],
12
- "exports": {
13
- ".": {
14
- "import": "./dist/index.js",
15
- "types": "./dist/index.d.ts"
16
- },
17
- "./types": "./dist/index.d.ts",
18
- "./styles.css": "./dist/styles.css",
19
- "./export-excel": {
20
- "import": "./dist/export/export-excel/index.js",
21
- "require": "./dist/export/export-excel/index.js",
22
- "types": "./dist/export/export-excel/index.d.ts"
23
- },
24
- "./export-word": {
25
- "import": "./dist/export/export-word/index.js",
26
- "require": "./dist/export/export-word/index.js",
27
- "types": "./dist/export/export-word/index.d.ts"
28
- }
29
- },
30
- "peerDependencies": {
31
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
32
- "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
33
- },
34
- "devDependencies": {
35
- "@types/file-saver": "^2.0.7",
36
- "@types/react": "^19.1.3",
37
- "@types/react-dom": "^19.1.3",
38
- "sass": "^1.87.0",
39
- "tsup": "^8.4.0",
40
- "typescript": "^5.8.3"
41
- },
42
- "optionalDependencies": {
43
- "docx": "^8.1.2",
44
- "exceljs": "^4.3.0",
45
- "file-saver": "^2.0.5"
46
- },
47
- "scripts": {
48
- "build": "tsup && npm run build:styles",
49
- "build:styles": "node build-styles.js"
50
- }
1
+ {
2
+ "name": "nillud-data-table",
3
+ "version": "1.4.5",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "style": "./dist/styles.css",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./types": "./dist/index.d.ts",
18
+ "./styles.css": "./dist/styles.css",
19
+ "./export-excel": {
20
+ "import": "./dist/export/export-excel/index.js",
21
+ "types": "./dist/export/export-excel/index.d.ts"
22
+ },
23
+ "./export-word": {
24
+ "import": "./dist/export/export-word/index.js",
25
+ "types": "./dist/export/export-word/index.d.ts"
26
+ }
27
+ },
28
+ "peerDependencies": {
29
+ "docx": "^8.1.2",
30
+ "exceljs": "^4.3.0",
31
+ "file-saver": "^2.0.5",
32
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
33
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/file-saver": "^2.0.7",
37
+ "@types/exceljs": "^4.3.1",
38
+ "@types/docx": "^8.1.2",
39
+ "@types/node": "^20.11.0",
40
+ "@types/react": "^19.1.3",
41
+ "@types/react-dom": "^19.1.3",
42
+ "sass": "^1.87.0",
43
+ "tsup": "^8.4.0",
44
+ "typescript": "^5.8.3"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup && npm run build:styles",
48
+ "build:styles": "node build-styles.js"
49
+ }
51
50
  }
@@ -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
- };