3

I am working with ExcelJS library in NodeJS for creating a excel file. What I need it's to generate a Base64 string from a Workbook object.

I have this code

let workbook = new Excel.stream.xlsx.WorkbookWriter({});
let worksheet = workbook.addWorksheet(`CREReport_${origcontractid}`);
worksheet.getCell('A1').value = 'CRE evolution';
worksheet.commit(); 

but I don't know how to generate a Base64 string based on my workbook. I don't want to create a file in my disk, i want to return in my webservice a base64 string which represent the file. any idea?

Thanks!

pbalasimon
  • 61
  • 3
  • 6

1 Answers1

6

with the file buffer you can get the base64.

const fileBuffer = await workbook.xlsx.writeBuffer()
Jorge Rolhas
  • 61
  • 1
  • 2