#1032·exceljs

writeBuffer doesn't return Buffer type

Author: TranBaVinhSonCreated Nov 22, 2019Updated Aug 21, 2026

Thanks for the great package. I'm using exceljs with Typescript, but writeBuffer() function returns ExcelJS.Buffer instead of Buffer type. And since ExcelJS.Buffer inherits from ArrayBuffer, converting ArrayBuffer to Buffer will break excel file. Does anyone have a solution to this problem? Thanks in advance!

typescript
declare interface Buffer extends ArrayBuffer { }
typescript
let resultExcel: Buffer; // buffer
const tmpResultExcel: ExcelJS.Buffer = await tmpWorkBook.xlsx.writeBuffer(); // arraybuffer
resultExcel = Buffer.from(tmpResultExcel); // doesn't work well