I am sending a .xlsx file through body form-data with key=excel, type=file, and value=text.xlsx. I want to read the values obtained from the excel file.
async create(data, params) {
console.log(data);
const { file } = data; // Assuming the file is sent as 'file' in form-data
const workbook = new ExcelJS.Workbook();
console.log(file);
console.log(data);
await workbook.xlsx.load(file.data); // Load the Excel file from binary data
const worksheet = workbook.worksheets[0]; // Select the first worksheet
const rows = [];
worksheet.eachRow((row, rowNumber) => {
const rowData = {};
row.eachCell((cell, colNumber) => {
rowData[`col${colNumber}`] = cell.value;
});
rows.push(rowData);
});

