Export excel not wokring For base64

Hello Synfusion Team,

We are trying to export images to excel after converting it into base64 but still we are not getting image in the excel

ts.file

async exportQueryCellInfo(args: ExcelQueryCellInfoEventArgs){
if (args.column.type == 'image') {
if ((args as any).name === 'excelQueryCellInfo') {
/*OUR custom method to get Base64*/
const imageName =(args as any).value?.split('/');
const imageType =imageName[imageName.length-1].split('.')
console.log(imageName[imageName.length-1],imageType[1])
const imageInBase64= await this.azureImageService.getImage(imageName[imageName.length-1],imageType[1]);
/*custom method ends
args.image = { height: 75, base64: imageInBase64, width: 75 };
console.log(args);
}
}
}


{

"data": {

**************************************************

"cost": 12,

"retail": 56,

"image": "https://***********.blob.core.windows.net/mY-images/organisation-1/645.png",

*************************************************

},

"column": {

*********************************************************

"type": "image",

"minWidth": 200,

******************************************************

},

"value": "https://*********.blob.core.windows.net/mY-images/organisation-1/645.png",

"colSpan": 1,

"cell": {

"index": 11,

"value": "https://********.blob.core.windows.net/mY-images/organisation-1/645.png",

"style": {

"name": "styleDefinitionGridcolumn11"

}

},

"name": "excelQueryCellInfo",

"image": {

"height": 75,

"base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFsAAABaCAYAAADXaio8AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAhsSURBVHhe7Z2HV1Q7EMbff27vBXsHxV6ODRUb6gEW0AW70u0VlyZYEZjHb3zhhT2Btx5gNuxLzvmOsMnNvfvd5MtkZoJ/SSrzXn7+/CkjIyOiZD969EhOnDiRME/o7u6W79+//ya7pqZGFi1alDBPaG5ulqGhoUS2BRobG6W/vz+RbYGGhoZEthWamppkYGAgkW2BpNmGePjwYbJGrNDe3i6/fv1KZFugq6tLxsfHE9kWYFNDSWQbIJFtiES2ITo6OmR0dDSRbYGnT5/+6/VLZM8vnjx5om7WRLYB7t69K1++fElkWwCvX/KNGKG2tlZyuVwi2wKJbEPU1dZJb643kW2B+vp66evtS2RbQMNiAylSY4Jscz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26DoEkWW7fvl37oF9eCPdkhNOOF85n7Fyx/f3nnw2KQjYkMH0ZPT4gBhmACP8aRiEjHX1lq85og1z/WhZKXqJPDtqNNcKLde2wQHxpYJRDuN8XEgLxXO/azQXMDzAxldFYRicLlw/35yvyt+PoNp+zIDLVeWH0EbrWSYG7FzOBOteO330Ssa35zO+L+2DVOFNwrpCCB4ZIwQNDIHPRnfAtVaT0M0NEecyjVIEnMdr87FKDefDg/4xEtiES2YbAwRbl0bxSRDL9DIGzi+yBRLYBsmm7bgc95oEjip1NDIfpSxmT/mzSwcihCDVKmBtM/gcTBEvxSvmZQQlzC4LIuVxO/gYAd6n+od/kMQAAAABJRU5ErkJggg==",

"width": 75

}

}

It is throwing below error



3 Replies 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team September 30, 2021 02:20 PM UTC

Hi Ansuman, 

Greetings from Syncfusion support 

Based on your query, we would like to inform you that by default in EJ2 Grid, image exporting is implemented based on base 64-bit string. If we want to export images to Excel or PDF, we have to use base64 string for required image for args.image parameter in pdfQueryCellInfo or excelQueryCellInfo. So, if you are using required images as URL in database, you have to convert this image URL to base64 string at your end then only it will work. This is demonstrated in the below sample demo example. 

Before we start providing solution on your query, we need some information for our clarification. Please share the below details that will be helpful for us to provide better solution. 

1)           Please share the details about why you are using async await in exportQueryCell info event. 

2)           Please share your exact requirement with detailed description. 

Regards, 
Rajapandi R 


Marked as answer

AP Ansuman Panda October 26, 2021 06:52 AM UTC

Thank you for sharing the demo.

Remove the  "data:image/png;" from the base64 it will work



RR Rajapandi Ravi Syncfusion Team October 27, 2021 05:55 AM UTC

Hi Ansuman, 

We are happy to hear that the provided solution works fine at our end. 

Please get back to us if you need further assistance. 

Rajapandi R 



Loader.
Up arrow icon