I have chart generated from highcharts using php and MySQL and I want to export the data to excel(xls) file a found many solution but all of them export data to csv file any solution?
-
exporting data means, you want to export chart to excel ? If yes, it already providing in highchart – Shafeeque Nov 06 '13 at 07:46
-
No, i want be able to download the raw data of the chart as Excel and not exporting the chart – Titi master Nov 06 '13 at 07:55
3 Answers
you can't :P
javascript doesn't know anything about excel a closed source desktop application however it does know csv which is basically a string but im not sure if you can trigger a download with javascript what you need in this case is a server-side language like php
so what i would do is - a high level list -
- identify the row i want to export by attaching an event handler
- make an ajax call to the 'backend' sending the id of the model and possibly the db table name or any other parameters that will help you get the model
handle that ajax call with php
3.1 make a database call requesting the whole model of that id
3.2 use some third-party library that creates excel files
3.3 trigger a download prompt
alternative step 2.
if you already have the model in json or as a javascript object you can serialize it and make an ajax call to the 'backend' and send it instead that would save you the db call and then you would unserialize in php and continue with step 3.2
it would really helpful if you could post link from the highcharts website with the type of the chart you are using e.g. is it a pie chart or a bar chart etc
maybe you can trigger a download with javascript after all but only on html5 compatible browsers Create a file in memory for user to download, not through server
-
thanks for help ,i will try to use PHPEXCEL like mmr suggest and use you're method with ajax – Titi master Nov 06 '13 at 10:36
You can try to use one of users plugin to export data to Excel: http://forum.highcharts.com/highcharts-usage/highchart-export-in-excel-t7816/page15.html

- 44,795
- 3
- 61
- 77