Noob question - new google.visualisation.Query - ReferenceError: google is not defined

2,742 views
Skip to first unread message

Jeremy Gooch

unread,
Mar 7, 2012, 5:53:28 AM3/7/12
to google-visua...@googlegroups.com
Hi,

I'm trying to write a Google spreadsheet macro to process a large stack of data (e.g. to create a list of unique values from a wide range so I can generate some column headings on another sheet).  I've previously used the Google query language API within Sites via data source URLs, so I thought I should be able to use a query within a JavaScript inside the source spreadsheet's script editor.

However, when I run the script, I receive the error:-
ReferenceError: "google" is not defined
at the line
var query = new google.visualisation.Query(--URL--).

This is the page I was using as guidance -> http://code.google.com/apis/ajax/playground/?type=visualization#using_the_query_language.  It seems to imply that it should just work.

I feel I've fallen at the first hurdle!   Is this API not compatible with spreadsheet scripts or is there something fundamental I've missed?  Do I somehow need to declare the library within the script editor?  I'm quite new to Google Apps and JavaScript but have long experience with VBA.  I've got a basic spreadsheet JavaScript working (just counting columns).  I've tried publishing the sheet but that didn't solve the error.

We're Google Apps users, so the source spreadsheet is within our corporate domain inside Google, if that makes any difference.

Thanks for any help,

J.

Viz Kid

unread,
Mar 7, 2012, 12:39:23 PM3/7/12
to google-visua...@googlegroups.com

While writing a Google App Script, you probably don't need to load the Google Visualization API for making queries. There is a service to spreadsheet data related tasks (http://code.google.com/googleapps/appsscript/service_spreadsheet.html). Also, there is a charts service to generate charts in spreadsheet from a script which might be useful for you (http://code.google.com/googleapps/appsscript/service_charts.html).

Hope this helps,
  Viz Kid

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/sDucOMa3rEoJ.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Jeremy Gooch

unread,
Mar 9, 2012, 7:15:18 AM3/9/12
to google-visua...@googlegroups.com
Hi,

Thanks for the reply.

I was hoping to use the query functionality within the API in order to select unique values from a large (3000x70) spreadsheet grid of data - which includes about 200 different values.  It seemed like an efficient approach rather than walking through the grid and building out an array.

Where I'm stuck, I think, is how one imports the API library into the spreadsheet script - perhaps a server-side version of:-
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
and then:-
google.load('visualisation','1');
??

To be honest, I've a feeling that my issue is with JavaScript syntax rather than this API in particular, although a complete working example (e.g. link to a Google spreadsheet) would really help.  The one on Google's page as per link below doesn't run.

J.



On Wednesday, March 7, 2012 5:39:23 PM UTC, Viz Kid wrote:

While writing a Google App Script, you probably don't need to load the Google Visualization API for making queries. There is a service to spreadsheet data related tasks (http://code.google.com/googleapps/appsscript/service_spreadsheet.html). Also, there is a charts service to generate charts in spreadsheet from a script which might be useful for you (http://code.google.com/googleapps/appsscript/service_charts.html).

Hope this helps,
  Viz Kid

On Wed, Mar 7, 2012 at 12:53 PM, Jeremy Gooch <jeremy.gooch@homeretailgroup.com> wrote:
Hi,

I'm trying to write a Google spreadsheet macro to process a large stack of data (e.g. to create a list of unique values from a wide range so I can generate some column headings on another sheet).  I've previously used the Google query language API within Sites via data source URLs, so I thought I should be able to use a query within a JavaScript inside the source spreadsheet's script editor.

However, when I run the script, I receive the error:-
ReferenceError: "google" is not defined
at the line
var query = new google.visualisation.Query(--URL--).

This is the page I was using as guidance -> http://code.google.com/apis/ajax/playground/?type=visualization#using_the_query_language.  It seems to imply that it should just work.

I feel I've fallen at the first hurdle!   Is this API not compatible with spreadsheet scripts or is there something fundamental I've missed?  Do I somehow need to declare the library within the script editor?  I'm quite new to Google Apps and JavaScript but have long experience with VBA.  I've got a basic spreadsheet JavaScript working (just counting columns).  I've tried publishing the sheet but that didn't solve the error.

We're Google Apps users, so the source spreadsheet is within our corporate domain inside Google, if that makes any difference.

Thanks for any help,

J.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/sDucOMa3rEoJ.
To post to this group, send email to google-visualization-api@googlegroups.com.
To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.

Jinji

unread,
Mar 11, 2012, 7:10:03 AM3/11/12
to google-visua...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/ep7BAdxjvLIJ.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.

ChartMan

unread,
Mar 11, 2012, 9:19:44 AM3/11/12
to google-visua...@googlegroups.com
Please have a look at the QUERY formula: http://support.google.com/docs/bin/answer.py?hl=en&answer=1388882

ChartMan



To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/ep7BAdxjvLIJ.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.

John Bowskill

unread,
Feb 5, 2014, 4:01:23 PM2/5/14
to google-visua...@googlegroups.com


On Friday, 9 March 2012 12:15:18 UTC, Jeremy Gooch wrote:
Hi,

Thanks for the reply.

I was hoping to use the query functionality within the API in order to select unique values from a large (3000x70) spreadsheet grid of data - which includes about 200 different values.  It seemed like an efficient approach rather than walking through the grid and building out an array.

Where I'm stuck, I think, is how one imports the API library into the spreadsheet script - perhaps a server-side version of:-
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
and then:-
google.load('visualisation','1');
??

To be honest, I've a feeling that my issue is with JavaScript syntax rather than this API in particular, although a complete working example (e.g. link to a Google spreadsheet) would really help.  The one on Google's page as per link below doesn't run.

J.



On Wednesday, March 7, 2012 5:39:23 PM UTC, Viz Kid wrote:

While writing a Google App Script, you probably don't need to load the Google Visualization API for making queries. There is a service to spreadsheet data related tasks (http://code.google.com/googleapps/appsscript/service_spreadsheet.html). Also, there is a charts service to generate charts in spreadsheet from a script which might be useful for you (http://code.google.com/googleapps/appsscript/service_charts.html).

Hope this helps,
  Viz Kid

On Wed, Mar 7, 2012 at 12:53 PM, Jeremy Gooch <jeremy...@homeretailgroup.com> wrote:
Hi,

I'm trying to write a Google spreadsheet macro to process a large stack of data (e.g. to create a list of unique values from a wide range so I can generate some column headings on another sheet).  I've previously used the Google query language API within Sites via data source URLs, so I thought I should be able to use a query within a JavaScript inside the source spreadsheet's script editor.

However, when I run the script, I receive the error:-
ReferenceError: "google" is not defined
at the line
var query = new google.visualisation.Query(--URL--).

This is the page I was using as guidance -> http://code.google.com/apis/ajax/playground/?type=visualization#using_the_query_language.  It seems to imply that it should just work.

I feel I've fallen at the first hurdle!   Is this API not compatible with spreadsheet scripts or is there something fundamental I've missed?  Do I somehow need to declare the library within the script editor?  I'm quite new to Google Apps and JavaScript but have long experience with VBA.  I've got a basic spreadsheet JavaScript working (just counting columns).  I've tried publishing the sheet but that didn't solve the error.

We're Google Apps users, so the source spreadsheet is within our corporate domain inside Google, if that makes any difference.

Thanks for any help,

J.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/sDucOMa3rEoJ.
To post to this group, send email to google-visua...@googlegroups.com.

To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

  
I have the same problem. I wanted to use "google.visualization" in the javascript associated with a google spreadsheet.

Like you I got  ReferenceError: "google" is not defined so the example does NOT WORK. It looked so powerful to do SQL like queries.
I notice that no-one answered your question correctly.

Any help please.

asgallant

unread,
Feb 6, 2014, 10:55:23 AM2/6/14
to google-visua...@googlegroups.com
If you would post your code, I'll take a look and see if I can find out what is wrong.

Mahii

unread,
Feb 15, 2014, 5:58:33 AM2/15/14
to google-visua...@googlegroups.com
I have the same problem. I wanted to use "google.transliteration" in the javascript. But it gaves me error as "ReferenceError: google is not defined". Please help me.

I have the same problem.
Reply all
Reply to author
Forward
0 new messages