next-recomponents 1.7.1 → 1.7.11
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.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/index.mjs +5 -1
- package/package.json +1 -1
- package/src/use-excel/index.tsx +16 -2
package/dist/index.d.mts
CHANGED
|
@@ -176,7 +176,7 @@ declare function useDates(): {
|
|
|
176
176
|
|
|
177
177
|
declare function useExcel(): {
|
|
178
178
|
import: (file: File) => Promise<any[][]>;
|
|
179
|
-
export: (data: any[]
|
|
179
|
+
export: (data: Record<string, any>[], fileName?: string) => Promise<void>;
|
|
180
180
|
exportAllPages: (data: Record<string, any[]>, fileName?: string) => Promise<void>;
|
|
181
181
|
importAllPages: (file: File) => Promise<Record<string, any[]>>;
|
|
182
182
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -176,7 +176,7 @@ declare function useDates(): {
|
|
|
176
176
|
|
|
177
177
|
declare function useExcel(): {
|
|
178
178
|
import: (file: File) => Promise<any[][]>;
|
|
179
|
-
export: (data: any[]
|
|
179
|
+
export: (data: Record<string, any>[], fileName?: string) => Promise<void>;
|
|
180
180
|
exportAllPages: (data: Record<string, any[]>, fileName?: string) => Promise<void>;
|
|
181
181
|
importAllPages: (file: File) => Promise<Record<string, any[]>>;
|
|
182
182
|
};
|
package/dist/index.js
CHANGED
|
@@ -44414,7 +44414,11 @@ function useExcel() {
|
|
|
44414
44414
|
}
|
|
44415
44415
|
function exportFile(data, fileName = "archivo.xlsx") {
|
|
44416
44416
|
return __async(this, null, function* () {
|
|
44417
|
-
|
|
44417
|
+
if (!data.length) return;
|
|
44418
|
+
const headers = Object.keys(data[0]);
|
|
44419
|
+
const rows = data.map((obj) => headers.map((header) => obj[header]));
|
|
44420
|
+
const finalData = [headers, ...rows];
|
|
44421
|
+
const worksheet = utils.aoa_to_sheet(finalData);
|
|
44418
44422
|
const workbook = utils.book_new();
|
|
44419
44423
|
utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
|
44420
44424
|
writeFileSync(workbook, fileName);
|
package/dist/index.mjs
CHANGED
|
@@ -44404,7 +44404,11 @@ function useExcel() {
|
|
|
44404
44404
|
}
|
|
44405
44405
|
function exportFile(data, fileName = "archivo.xlsx") {
|
|
44406
44406
|
return __async(this, null, function* () {
|
|
44407
|
-
|
|
44407
|
+
if (!data.length) return;
|
|
44408
|
+
const headers = Object.keys(data[0]);
|
|
44409
|
+
const rows = data.map((obj) => headers.map((header) => obj[header]));
|
|
44410
|
+
const finalData = [headers, ...rows];
|
|
44411
|
+
const worksheet = utils.aoa_to_sheet(finalData);
|
|
44408
44412
|
const workbook = utils.book_new();
|
|
44409
44413
|
utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
|
44410
44414
|
writeFileSync(workbook, fileName);
|
package/package.json
CHANGED
package/src/use-excel/index.tsx
CHANGED
|
@@ -55,8 +55,22 @@ export default function useExcel() {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
async function exportFile(
|
|
59
|
-
|
|
58
|
+
async function exportFile(
|
|
59
|
+
data: Record<string, any>[],
|
|
60
|
+
fileName = "archivo.xlsx"
|
|
61
|
+
) {
|
|
62
|
+
if (!data.length) return;
|
|
63
|
+
|
|
64
|
+
// Encabezados (keys del primer objeto)
|
|
65
|
+
const headers = Object.keys(data[0]);
|
|
66
|
+
|
|
67
|
+
// Filas (valores en el orden de los headers)
|
|
68
|
+
const rows = data.map((obj) => headers.map((header) => obj[header]));
|
|
69
|
+
|
|
70
|
+
// Combinamos encabezados + filas
|
|
71
|
+
const finalData = [headers, ...rows];
|
|
72
|
+
|
|
73
|
+
const worksheet = XLSX.utils.aoa_to_sheet(finalData);
|
|
60
74
|
const workbook = XLSX.utils.book_new();
|
|
61
75
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
|
62
76
|
|