I'm trying to figure out the most robust way to determine the ordinal position of a column in a google sheet from a row feed, not a cell feed.
So, for example, I have the following spreadsheet:
A B C D
+----+-----------------------------------------+
Header Row | 1 | name | address | phone | email |
+----+---------+-----------+---------+---------|
| 2 | Jane | 1001 | 6139023 | w@gmail |
+----+---------+-----------+---------+---------+
| 3 | Jon | 1102 | 4320909 | x@gmail |
+----+---------+-----------+---------+---------+
| 4 | Jeff | 1203 | 4132323 | y@gmail |
+----+---------+-----------+---------+---------+
| 5 | Jenny | 1304 | 3346044 | z@gmail |
+----+---------+-----------+---------+---------+
In my code, I'm able to successfully fetch a row-based feed from the sheet via Google's Sheet's API. The object I get back for each row in the feed includes various properties, most of which are the values in the header row. So for example, a single row object looks something like:
{
id : 'https://spreadsheets.google.com/...'
, 'app:edited' : '2017-02-24T23:59:56:56.520Z'
, _links : [ self: 'https://...', edit: 'https://...']
, name : 'Jane'
, address : '1001'
, phone : '6139023'
, email : 'w@gmail'
}
I want to find the ordinal position of any given column from the row-based feed, but it doesn't seem immediately obvious how to do this. It does seem the object's properties are ordered according to their position in the header row, but I'm hard pressed to find which column number the property refers to.
The reason I want the column number is that I want to get a cells-based feed for a particular column and row, but it appears Google's API requires that you know the ordinal position of the column. That is, you need to know the min-column and max-column, as well as a min-row and max-row for a cells based feed. Now, I know that I can obviously look at the column in the Sheets UI and determine which position the column is in, but how can I do it programatically?
In sum, I'm trying to find a programmatic way to answer a simple question such as question:
"What is the ordinal position of the phone
column?"
Is this even possible with Google's row-feed response?