response.getDataTable() returns a google.visualization.DataTable instance. You can find the documentation for that here <https://developers.google.com/chart/interactive/docs/datatables_dataviews?hl=en>, and the full API reference here <https://developers.google.com/chart/interactive/docs/reference#DataTable>.
Seems like the method you're looking for is data.getValue(row, column); On Fri, Sep 25, 2015 at 2:56 PM <[email protected]> wrote: > Hi Sergey, > > Thanks for your reply. I tried with the code below but still nothing. > > What I'm trying to do is to being able to store in a variable the value > from a particular cell in a Google Sheet. Let's say that I want to read > cell A2 from the table: > > Name Last Name Age > John Smith 26 > > Where I should get value for A2 = Smith so I store that value in a > variable and use it. > > How can I do that? > > Thank you very much > > After getting the Data through > > var data = response.getDataTable(); > > I tried to do var info = data[0,1]; > > I know that's not the way it works but that's the concept I'm trying to do > and I'm not able to find documentation on how to do that. > > *THANK YOU VERY MUCH AGAIN* > > function drawSheetName() { > var queryString = encodeURIComponent('SELECT A, B, C, D'); > var magicIncantation = '/gviz/tq?gid=0&headers=1&tq='; > > var query = new google.visualization.Query( > ' > https://docs.google.com/spreadsheets/d/1c34jIRfIeuh-rzr8VS7rPw168nJkflvWNpLR2de3KZw' > + > magicIncantation + queryString); > query.send(handleSampleDataQueryResponse); > > } > > > function handleSampleDataQueryResponse(response) { > if (response.isError()) { > alert('Error in query: ' + response.getMessage() + ' ' + > response.getDetailedMessage()); > return; > } > > var data = response.getDataTable(); > var info = data[0,1]; > > var chart = new > google.visualization.ColumnChart(document.getElementById('Columnchart_div')); > chart.draw(data, optionsColumnChart); > > } > > > > On Friday, September 25, 2015 at 1:22:06 PM UTC-5, Sergey wrote: > >> Hi Samuel, >> >> You can't use a Query the way you're using it. >> >> Firstly, the query must be sent first, since it's a request to Sheets. It >> doesn't immediately send when you construct it. You have to do so >> explicitly via query.send(). >> Secondly, queries are asynchronous, which means that you have to provide >> a callback for the result, since it won't be available immediately after a >> query was sent, but some indeterminate amount of time later. >> Thirdly, query[1, 1] is not valid JavaScript. >> And finally, a query will return a JSON object that may be an error or a >> DataTable, so you'll have to check the response. >> >> We have fairly extensive documentation for Query, which you can find here >> <https://developers.google.com/chart/interactive/docs/queries>. I think >> you'll have better luck following the documentation examples than trying >> random things. >> >> On Fri, Sep 25, 2015 at 2:08 PM <[email protected]> wrote: >> > So I do a query to a Google Sheet as Below but I get the whole column. >>> >>> How can I get a particular value of that query? >>> >>> Let's said that I'm queering this table: >>> >>> Name Last Name Age >>> John Smith 26 >>> >>> After I execute the query SELECT B, C WHERE A = John >>> >>> I would like to introduce in a variable the values Smith and 26. >>> >>> something like: >>> >>> var LastName = query [1,1] >>> var Age = = query [1,2] >>> >>> This is what I tried so fat and didn't work: >>> >>> var Area = query[0].value; >>> var Area = query[0]; >>> var Area = query[1,1].value; >>> var Area = query[1,1]; >>> >>> Code below. >>> >>> var dataSourceUrl = ' >>> https://docs.google.com/spreadsheets/d/1xfb9trifQA5KDPc9Nh5hBL4MJ290Mxcc1Uod2VTPzYI >>> '; >>> var magicIncantation = '/gviz/tq?sheet=Sheet1&headers=1&tq='; >>> >>> >>> var queryStringInfo = encodeURIComponent("SELECT C WHERE A = >>> 'Alabama'"); >>> query = new google.visualization.Query(dataSourceUrl + >>> magicIncantation + queryStringInfo); >>> var Area = query[0].value; >>> var Area2 = query[1].value; >>> var Area3 = query[1,1].value; >>> >>> *THANK YOU SO MUCH!!!!* >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google Visualization API" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> >> To post to this group, send email to [email protected]. >> >> >>> Visit this group at >>> http://groups.google.com/group/google-visualization-api. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/google-visualization-api/572d7d5f-8bba-43f9-b2f9-9d5d5ec70e60%40googlegroups.com >>> <https://groups.google.com/d/msgid/google-visualization-api/572d7d5f-8bba-43f9-b2f9-9d5d5ec70e60%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > http://groups.google.com/group/google-visualization-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-visualization-api/f2353359-c0de-4539-a60e-fabb4f2e30c1%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/f2353359-c0de-4539-a60e-fabb4f2e30c1%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAEwwup6nixQXMMZ3L-ryC%2BoidKCFaEKqk85iQvhqUOwcF5rZng%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
