Why does opening a CSV file in Excel break my Highcharts chart?

141 views Asked by At

I'm working on using CSV files to create Highcharts – but running into an odd problem: when Excel 'touches' a CSV file, the chart breaks immediately. Here's the simplest example:

Highcharts online documentation has a handy example of a bar chart generated from a CSV file: http://www.highcharts.com/studies/data-from-csv.htm The data underlying this chart can be downloaded from: http://www.highcharts.com/studies/data.csv

But here's the odd thing. If I download those files, and recreate the chart on my own web server, everything works fine... until I open the data.csv file in Excel, then save it. This breaks the Highchart immediately, even if no changes are made to the underlying data. No error messages are thrown up in the console – the chart simply goes blank as soon as Excel makes a save.

I know what you're thinking – "this moron is saving a CSV file as a .xslx, then wondering why his chart breaks." But that's not what's happening – using the 'Save As... .csv' option in Excel also breaks the chart immediately.

Here's the content of the CSV file before I open it in Excel (cut and pasted from TextEdit):

Categories,Apples,Pears,Oranges,Bananas
John,8,4,6,5
Jane,3,4,2,3
Joe,86,76,79,77
Janet,3,16,13,15

And here's the content of the CSV file after opening it in Excel:

Categories,Apples,Pears,Oranges,Bananas
John,8,4,6,5
Jane,3,4,2,3
Joe,86,76,79,77
Janet,3,16,13,15

To my eyes, those are the same file! And yet the first one renders perfectly, the second (which has been saved by Excel) creates an invisible chart.

Any help greatly appreciated. I'm using Excel 2008 for Mac, if that's relevant. Thanks in advance...

1

There are 1 answers

0
pnuts On

Seems the solution was to save:

the CSV file as a 'Windows comma separated CSV'