DHuser
Posts: 1
Joined: Thu May 12, 2022 4:59 am

How do I receive Excel files for multiple charts?

I found the code here and used it.

downloadButton.onclick = function() {
Highcharts.charts.forEach(chart => {
chart.downloadXLS()
})
}
However, there was no error on the first screen, but if i call another chart through Ajax and try again, the following error occurs.

error code => list.do:3928 Uncaught TypeError: Cannot read properties of undefined (reading 'downloadXLS')

Is the arrow function an error caused by calling the object in the window? If so, how else should I write the arrow function?
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: How do I receive Excel files for multiple charts?

Hi DHuser,

Welcome to our forum and thanks for contacting us with your question!

I've tried to reproduce the issue, but everything seems to work correctly:
https://jsfiddle.net/BlackLabel/savhj38c/

The arrow function in this case shouldn't make any difference because you refer directly to Highcharts.charts array elements.\

Please try to recreate the problem in the shared jsFiddle.

Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”