Google spreadsheet, jsapi Datatable, header row

Embedded in google's visualization jsapi is a simple way to grab data from a google spreadsheet. The data is captured in the form of a DataTable. Google's dev docs mention this in the context of using their charting/visualisation library but it is such a simple way to maintain and read tabular data that I use it for other things too.

The first time you do this you may (or may not) find that the data table has used the first row of your spreadsheet as column labels. If the first row is used like this then it will be absent from the rows of data available through the table interface.

The glitch...

I changed the type of data used in one of my spreadsheet columns from dates to strings. Once I did this, every column was then entirely composed of strings. At this point, my header-row ceased to be used as column labels and became the first row of data instead. Once I untangled this from the other changes I had made, I realised that having at least one non-string column in the spreadsheet was enough to convince the API to use the header-row (which is composed entirely of strings) as column labels again.


If you want more control in accessing a google spreadsheet, you might consider using the google sheets REST API instead.

Justin Hellings

"Justin? Hell of a guy! We would have kept him but you know how it is. Genius like that is always restless ... Eh? ... Oh, him ... No, I thought you meant someone else."

comments powered by Disqus