1

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?

3 Answers3

1

then you can use PHPExcel. It is an easy utility for exporting your data to excel

mmr
  • 516
  • 11
  • 30
1

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 -

  1. identify the row i want to export by attaching an event handler
  2. 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
  3. 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

Community
  • 1
  • 1
alex
  • 646
  • 9
  • 19
0

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

Paweł Fus
  • 44,795
  • 3
  • 61
  • 77