addRowsToWorkbookVariant(worksheetObject, dataArray, SupplierId, wrkbook) {
const excelObjectImgs = new ExcelManager();
var data = null;
// var workbook = excelObjectImgs.createWorkBook();
if (dataArray != undefined && dataArray.length > 0) {
var iLength = dataArray.length;
var imagepath = "Website_URL/Images/Products/" + SupplierId + "/Thumbnail/";
for (var p = 0; p < iLength; p++) {
//var img1 = imagepath + dataArray[2].ImageName;
var img1='Path of a image from Server';
var ext = img1.slice((img1.lastIndexOf(".") - 1 >>> 0) + 2)
if (ext == 'jpg') {
ext = 'jpeg';
console.log(ext);
}
console.log(img1);
var ImageFile = wrkbook.addImage({
// filename: img1,
filename:'./Images/test/01_16102019_Demo.jpg',
extension: ext
});
console.log(ImageFile);
worksheetObject.addImage(ImageFile, 'A2:A2');
worksheetObject.addRow(dataArray[p]);
}
console.log(dataArray);
}
}
当前使用上述方法通过ExcelJS在excel中下载图像。
为此,必须将每个映像存储在本地Node存储库中,但这会增加节点存储库的大小! 例如。文件名:'./ Images / test / 01_16102019_Demo.jpg',
是否有任何解决方案可将图像从(服务器路径)URL转换为base64并将其导出到Excel,而无需将其保存到本地存储库 例如。 var imagepath =“网站URL /图片/产品/” + SupplierId +“ /缩略图/”;