I've been attempting to export some data along with an image into Excel, but I keep encountering the error message TypeError: u.readFile is not a function. Despite trying alternative methods like buffer and base64, they all result in similar errors, such as TypeError: XXX is not a function. Below is the snippet of code from my app.component.ts file. I'm currently using Angular 13.2.0, so any help or suggestions would be greatly appreciated!
import * as FileSaver from 'file-saver';
import { Workbook } from 'exceljs';
exportFile(){
let workbook = new Workbook();
let worksheet = workbook.addWorksheet('sheet1');
let header = ['Days Ordered', 'Times Range', 'Total Spots', 'Air Date', 'Day', 'Time', 'Length', 'Sub Total'];
worksheet.addRow(header);
//add image
const image = workbook.addImage({
filename: 'assets/logo.png',
extension: 'png',
});
worksheet.addImage(image, "A1:B3");
workbook.xlsx.writeBuffer().then((data) => {
let blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
FileSaver.saveAs(blob, 'AdReport'+'-'+new Date().valueOf()+'.xlsx');
});
}