I am trying to access the following Google spreadsheet:
https://docs.google.com/spreadsheets/d/1E77UIqc5VD0KFjJjHK_dLbWBl7bw8_eUmeUcxxAA6sM/edit#gid=1380168487
According to the docs, the following code should do the trick:
<google-sheets id="sheet" key="1E77UIqc5VD0KFjJjHK_dLbWBl7bw8_eUmeUcxxAA6sM" gid="1380168487" published></google-sheets>
However, I am getting the following error on my console:
XMLHttpRequest cannot load https://spreadsheets.google.com/feeds/list/1E77UIqc5VD0KFjJjHK_dLbWBl7bw8_eUmeUcxxAA6sM/mtpx19/public/values?alt=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 400.
When I load the above feed URL, https://spreadsheets.google.com/feeds/list/1E77UIqc5VD0KFjJjHK_dLbWBl7bw8_eUmeUcxxAA6sM/mtpx19/public/values?alt=json in my browser, I see the following error message:
Invalid query parameter value for grid_id.
After a bit of research, I found this thread on Google Groups, which explains that the format of the second parameter in that URL has changed, and suggests to try the value '1' instead.
Since the value is computed by the gid_to_wid
function inside the <google-sheets>
tag, I tried patching line 118 to say return 1;
instead (alternatively, we could set the gid
attribute to 31579
, which produces the same result).
Now, the sheet is loaded correctly and I can access its contents through the rows
property on the <google-sheets>
tag.
If this is a permanent change in the Google Spreadsheets API, this component should probably be updated to reflect that.