@cdmx/wappler_ag_grid 1.9.5 → 1.9.6

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.
@@ -3176,8 +3176,8 @@
3176
3176
  "dst": "js/papaparse.js"
3177
3177
  },
3178
3178
  {
3179
- "src": "../../../node_modules/exceljs/dist/exceljs.min.js",
3180
- "dst": "js/exceljs.min.js"
3179
+ "src": "../../../node_modules/read-excel-file/bundle/read-excel-file.min.js",
3180
+ "dst": "js/read-excel-file.min.js"
3181
3181
  },
3182
3182
  {
3183
3183
  "src": "../../../node_modules/pdfmake/build/pdfmake.min.js",
package/dmx-ag-grid.js CHANGED
@@ -394,37 +394,36 @@ dmx.Component('ag-grid', {
394
394
  });
395
395
  };
396
396
 
397
- const parseExcel = (excelData) => {
397
+ const parseExcel = (file) => {
398
398
  return new Promise((resolve, reject) => {
399
- const workbook = new ExcelJS.Workbook();
400
- workbook.xlsx.load(excelData)
401
- .then(() => {
402
- const worksheet = workbook.getWorksheet(1);
403
- const data = [];
404
- const headers = [];
405
-
406
- worksheet.eachRow((row, rowNumber) => {
407
- if (rowNumber === 1) {
408
- row.eachCell((cell) => {
409
- headers.push(cell.value);
410
- });
399
+ const headers = [];
400
+ const data = [];
401
+ readXlsxFile(file)
402
+ .then((rows) => {
403
+ rows.forEach((row, rowIndex) => {
404
+ if (rowIndex === 0) {
405
+ // First row contains headers
406
+ headers.push(...row);
411
407
  } else {
408
+ // Map data rows to objects using the headers
412
409
  const rowData = {};
413
- row.eachCell({ includeEmpty: true }, (cell, colNumber) => {
414
- rowData[headers[colNumber - 1]] = cell.value;
410
+ row.forEach((cell, colIndex) => {
411
+ // Use headers to map values to the respective columns
412
+ rowData[headers[colIndex]] = cell;
415
413
  });
416
414
  data.push(rowData);
417
415
  }
418
416
  });
419
-
417
+ // Resolve the promise with the parsed data
420
418
  resolve(data);
421
419
  })
422
420
  .catch((error) => {
421
+ // Reject the promise in case of an error
423
422
  reject(error.message);
424
423
  });
425
424
  });
426
425
  };
427
-
426
+
428
427
  const fileInput = document.getElementById(fieldId);
429
428
  if (!fileInput) {
430
429
  console.error('Field having field Id: '+fieldId+' not found.');
@@ -438,19 +437,17 @@ dmx.Component('ag-grid', {
438
437
  const reader = new FileReader();
439
438
  reader.onload = async (e) => {
440
439
  const fileData = e.target.result;
441
-
442
440
  try {
443
441
  let parsedData;
444
442
  // Detect the file type based on the file extension or other criteria
445
443
  if (file.name.endsWith('.csv')) {
446
444
  parsedData = await parseCSV(fileData);
447
445
  } else if (file.name.endsWith('.xlsx') || file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
448
- parsedData = await parseExcel(fileData);
446
+ parsedData = await parseExcel(file);
449
447
  } else {
450
448
  console.error('Unsupported file type. Please select a CSV or Excel file.');
451
449
  return;
452
450
  }
453
-
454
451
  this.set('fileData', parsedData);
455
452
  } catch (error) {
456
453
  console.error('Error parsing file:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",
@@ -14,10 +14,10 @@
14
14
  "ag-grid"
15
15
  ],
16
16
  "dependencies": {
17
- "ag-grid-community": "^32.3.3",
18
- "exceljs": "~4.4.0",
17
+ "ag-grid-community": "~32.3.3",
19
18
  "papaparse": "~5.4.1",
20
- "pdfmake": "~0.2.16"
19
+ "pdfmake": "~0.2.16",
20
+ "read-excel-file": "~5.8.6"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "rollup --config",