so i trying to create a xlx file from the input and upload it to S3 bucket so
when i pass large data say 1000 rows I could see that only column headers are created in the file not the data but still the file size is around 100kb
but if i send small input i could see the rows getting created
any help is much appreciated
attaching the snippet of the code where i am trying to create xlsx file
await Promise.all(
payload.queryResults.map(async (queryResult: QueryResult) => {
const { columnHeader, strId, queryName, data = [] } = queryResult;
try {
// Process the Excel file
const workbook = new ExcelJS.Workbook();
const worksheet = workbook.addWorksheet('Sheet1');
worksheet.addRow(columnHeader);
// Add data rows only if `data` is a non-empty array
if (Array.isArray(data) && data.length > 0) {
data.forEach((row) => {
const rowData = columnHeader.map(col => row[col] || '');
worksheet.addRow(rowData);
});
}
const filePath = filename.xlsx`;
const buffer = await workbook.xlsx.writeBuffer();
await uploadFiletoS3(stagingBucket, filePath, Buffer.from(buffer));
successfulQueries.push({ queryName, strId });
} catch (uploadError) {
failedQueries.push({ queryName, strId, error: uploadError.message });
logger.error(`Error uploading file for query: ${queryName} for store: ${strId}`, { error: uploadError });
}
})
);