我试图使用exceljs添加图像,但是当我试图添加图像时,fs.readFile不是函数。这是控制台中的错误。

这是我为excel添加图像的代码。
const imagePath = path.resolve('img/logo.jpg');
const imageId = workbook.addImage({
filename: imagePath,
extension: 'jpg'
});
worksheet.addImage(imageId, 'B3:C3');
worksheet.mergeCells('B3:C3');发布于 2022-10-05 16:05:29
// add image to workbook by buffer
const imageBuffer = await axios.get('path/to.image.png', { responseType: 'arraybuffer' });
const imageId2 = workbook.addImage({
buffer: imageBuffer.data,
extension: 'png',
});
https://stackoverflow.com/questions/73931079
复制相似问题