Kendo spreadsheet: Creating a custom handler for the excelExport event and then exporting a spreadsheet with images via saveAsExcel result in an error

2 Answers 277 Views
Spreadsheet
Mario
Top achievements
Rank 1
Mario asked on 18 May 2021, 05:03 PM

My goal is to handle the exportExcel event,  invoke the export saveAsExcel function, then pass the excel data to the server as a base64 string.
However if the spreadsheet contains images, and unhandled error occurs in the kendo script, which I have managed to track down via the unminified kendo.all.js and it seems to occur at this place:

'images is not defined' is the error message.

I've created Dojos which illustrate and reproduce the problem.
Clicking on the "Export" button will trigger the excel export:
 - Non-working Dojo with an image: https://dojo.telerik.com/AdIWETEY/15
 - Working Dojo (without images): https://dojo.telerik.com/iRebuTuV

2 Answers, 1 is accepted

Sort by
1
Neli
Telerik team
answered on 26 May 2021, 08:12 AM

Hi Mario,

I have debugged the provided samples and noticed that the images data is not presented in the e.workbook in the excelExport event handler (marked in yellow below):

excelExport: e => {
                e.preventDefault();              
                const dataURL = new kendo.ooxml.Workbook(e.workbook).toDataURL();
        	const base64 = dataURL.split(';base64,')[1];
                exportedWorkbooks.push(base64);
},

The issue is related to a bug that you will find linked below:

https://github.com/telerik/kendo-ui-core/issues/6411

In the GitHub issue, you will find also a suggestion for retrieving the images data. 

Based on your report I have increased the priority of the issue. Thus, it could take precedence over other items in our priority queue.

I hope you will find the provided information helpful.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Mario
Top achievements
Rank 1
commented on 26 May 2021, 01:53 PM

Hi Neli,
Thank you for the swift response. We will implement the workaround if it's viable for our case. If not, we will wait for an update.
0
Neli
Telerik team
answered on 21 May 2021, 08:27 AM

Hello Mario,

Please note that, as it is described in the Spreadsheet API, when external URLs are used for the images, they should reside on the same domain, or the server must be configured with the proper CORS headers, for the Spreadsheet to be able to fetch binary image data using a XMLHttpRequest. If it cannot fetch the image, export to Excel or PDF might not work.

I hope this helps.

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mario
Top achievements
Rank 1
commented on 21 May 2021, 08:46 AM

Hello and thanks for the response.
The images are not external - In fact, they are imported via the import function and the issue still persists with the same error...
Tags
Spreadsheet
Asked by
Mario
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or