Animik
Animik

Reputation: 319

Filename not assigned to csv export in HighCharts on Mac

I am using the EXPORT-CSV plugin for Highcharts to export data to csv. (Thank you to the developers of this plugin!) When testing in Safari on a Mac, however, the exported csv file does not take the filename as expected from

exporting: {
    filename: "FancyFileName"
}

and instead just uses the default Highcharts name "chart". All the built-in export types do use the desired filename from Safari, and the csv also gets the desired filename from all the other standard browsers I have tested.

Here is a fiddle.

How can Safari be convinced to use the filename I give it? Thanks for your help.

Upvotes: 2

Views: 257

Answers (1)

Asiya Shaikh
Asiya Shaikh

Reputation: 59

The hard coded filename is coming from the php script written on the server. You can find that script on php script for download of file with hardcoded file name

You can use that same code on your local machine server. To do that

  1. create a php file on your local server.
  2. copy the above code in it.
  3. change url www.highcharts.com/studies/csv-export/csv.php in export.csv library to your local server url.
  4. change the name whatever you wish to using $_POST['variablename']

Variable name should be pass when making post call from export.csv library and use in php file using $_POST

Highcharts.post(url, {
            data: content,
            name: name,
            type: MIME,
            extension: extension
        });

This is the code used in export.csv library for making post call. I have added extra parameter name to be used in my php script for dynamic filename.

Upvotes: 2

Related Questions