How to export image to EXCEL

In synfusion grid while exporting to excel we are getting the image URL instead of image.
We want to export image into the excel.

I am trying with excelQueryCellInfo but not getting any results to convert Please help. The image URL is stored in value(args.value)

excelQueryCellInfo(args:any){
if (args.column.type == 'image') {
console.log(args)
}

console value:

{
"data": {
*************************************************
},
"column": {
"disableHtmlEncode": true,
"allowSorting": true,
"allowResizing": true,
***********************************************
"index": 9
},
"value": "https://svmvpitemgroup.blob.core.windows.net/mi-images/organisation-1/1728.png",
"colSpan": 1,
"cell": {
"index": 10,
"value": "https://svmvpitemgroup.blob.core.windows.net/mi-images/organisation-1/1728.png",
"style": {
"name": "styleD10"
}
},
"name": "excelQueryCellInfo"
}

2 Replies 1 reply marked as answer

AP Ansuman Panda September 21, 2021 07:13 AM UTC

Hello

Can you please help?




PG Praveenkumar Gajendiran Syncfusion Team September 21, 2021 10:47 AM UTC

Hi Ansuman,

Thanks for contacting 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 code example.

Please check the below sample, online demo and code example for your reference.

Sample: https://stackblitz.com/edit/angular-iwaxft?file=app.component.ts

Online Demo: https://ej2.syncfusion.com/angular/demos/#/material/grid/default-exporting 
Code example: 
exportQueryCellInfo(args: ExcelQueryCellInfoEventArgs | PdfQueryCellInfoEventArgs): void { 
        if (args.column.headerText === 'Employee Image') { 
            if ((args as any).name === 'excelQueryCellInfo') { 
                args.image = { height: 75, base64: (args as any).data.EmployeeImage, width: 75 }; 
            } else { 
                args.image = { base64: (args as any).data.EmployeeImage }; 
            } 
        } 
   } 

Please get back to us if you need further assistance.

Regards,
Praveenkumar G 


Marked as answer
Loader.
Up arrow icon