josenanodev-react-components-library 0.1.4 → 0.1.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.
|
@@ -49,11 +49,12 @@ function styleObjectParser(styleObject) {
|
|
|
49
49
|
}
|
|
50
50
|
function downloadExcel(fileName, data, headers) {
|
|
51
51
|
if (data !== undefined) {
|
|
52
|
-
const
|
|
52
|
+
const workbook = XLSX.utils.book_new();
|
|
53
53
|
for (const sheetName in data) {
|
|
54
54
|
if (Object.prototype.hasOwnProperty.call(data, sheetName)) {
|
|
55
55
|
let dataXlsxJs = [];
|
|
56
|
-
if (headers !== undefined
|
|
56
|
+
if (headers !== undefined &&
|
|
57
|
+
Object.prototype.hasOwnProperty.call(headers, sheetName)) {
|
|
57
58
|
dataXlsxJs = [
|
|
58
59
|
headers[sheetName].map((header) => styleObjectParser(header)),
|
|
59
60
|
...data[sheetName].map((row) => row.map((cell) => styleObjectParser(cell))),
|
|
@@ -64,11 +65,11 @@ function downloadExcel(fileName, data, headers) {
|
|
|
64
65
|
...data[sheetName].map((row) => row.map((cell) => styleObjectParser(cell))),
|
|
65
66
|
];
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
XLSX.utils.book_append_sheet(
|
|
68
|
+
const worksheet = XLSX.utils.aoa_to_sheet(dataXlsxJs);
|
|
69
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
XLSX.writeFile(
|
|
72
|
+
XLSX.writeFile(workbook, `${fileName}.xlsx`);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
exports.downloadExcel = downloadExcel;
|
|
@@ -23,11 +23,12 @@ function styleObjectParser(styleObject) {
|
|
|
23
23
|
}
|
|
24
24
|
export function downloadExcel(fileName, data, headers) {
|
|
25
25
|
if (data !== undefined) {
|
|
26
|
-
const
|
|
26
|
+
const workbook = XLSX.utils.book_new();
|
|
27
27
|
for (const sheetName in data) {
|
|
28
28
|
if (Object.prototype.hasOwnProperty.call(data, sheetName)) {
|
|
29
29
|
let dataXlsxJs = [];
|
|
30
|
-
if (headers !== undefined
|
|
30
|
+
if (headers !== undefined &&
|
|
31
|
+
Object.prototype.hasOwnProperty.call(headers, sheetName)) {
|
|
31
32
|
dataXlsxJs = [
|
|
32
33
|
headers[sheetName].map((header) => styleObjectParser(header)),
|
|
33
34
|
...data[sheetName].map((row) => row.map((cell) => styleObjectParser(cell))),
|
|
@@ -38,10 +39,10 @@ export function downloadExcel(fileName, data, headers) {
|
|
|
38
39
|
...data[sheetName].map((row) => row.map((cell) => styleObjectParser(cell))),
|
|
39
40
|
];
|
|
40
41
|
}
|
|
41
|
-
const
|
|
42
|
-
XLSX.utils.book_append_sheet(
|
|
42
|
+
const worksheet = XLSX.utils.aoa_to_sheet(dataXlsxJs);
|
|
43
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
XLSX.writeFile(
|
|
46
|
+
XLSX.writeFile(workbook, `${fileName}.xlsx`);
|
|
46
47
|
}
|
|
47
48
|
}
|