Using Excel Spreadsheet for Column Chart

178 views
Skip to first unread message

Molasses26

unread,
Apr 17, 2012, 6:36:51 PM4/17/12
to Google Visualization API
Hi! I have an Excel Spreadsheet with the following data:

Year: 2011 2012
Jan 4802 5178
Feb 4688 5989
Mar 4764 5556
Apr 4813
May 4813
etc.....

I would like to refer to this spreadsheet to create a Google Column
Chart.

Can you please show me the correct code to refer to my Excel
Spreadsheet?
I have created the charts by coding the data in directly:
=======================================
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
data.addColumn('number', '2011');
data.addColumn('number', '2012');
data.addRows([
['Jan', 4802, 5178],
['Feb', 4688, 5989],
['Mar', 4764, 5556],
['Apr', 4813, ],
. . . . .
=======================
But I don't know how to make it refer to the spreadsheet instead.
Thanks!

asgallant

unread,
Apr 18, 2012, 10:11:56 AM4/18/12
to google-visua...@googlegroups.com
There is no out-of-the-box support for querying from an Excel spreadsheet.  The easiest thing to do (in terms of coding) is to convert your Excel sheet into a Google Docs spreadsheet and query that, which we can help you with if you want.  If you don't want to or can't do that, then it depends on whether the spreadsheet is located client-side or server-side.  If the file is server-side, then you need to read in the contents and output them in a format the charts can understand (ie, javascript array or JSON string) using whatever server-side processing you use (PHP, perl, Java, ASP, Python, etc).  If the file is client-side, then you'll have to figure out how to do a file read from javascript (Google it) and parse the contents into something the charts can understand.  I wish you luck in this endeavor, as MS Office files aren't exactly easy to parse.
Reply all
Reply to author
Forward
0 new messages