1

I would like to ask if its possible to fetch all the content of a spreadsheet in google docs via api. This is my code currently:

$sheets = Google::make('sheets');
$spreadsheet_id = "19L9K1uMgAjwIVHrpFftQyQ0n00lVIzDYspZx8ZpnnFk";
print_r($sheets->spreadsheets_values->get($spreadsheet_id,"A1:B3")->getValues());

I can fetch all the rows in the spreadsheet using the above code but my problem is I need to manually add the Cell Number in the second parameter of "get" so basically when I add an additional rows in the spreadsheet I need to manually update my code based on the number of cells. Is there a way that I can fetch all rows without manually declaring the cells?

This is the google api that I used: https://github.com/pulkitjalan/google-apiclient

Thanks!

Sydney Loteria
  • 10,171
  • 19
  • 59
  • 73
  • 1
    You can try to set the range widely or "A2:D" in your case and this would fetch as far as the last data row in your sheet. For more information, try to check this [SO question](http://stackoverflow.com/questions/38607775/finding-last-written-row-in-google-spreadsheet-api). – KENdi Feb 10 '17 at 13:27
  • @KENdi, I just put A1:Z because the range of columns is indefinite/dynamic. Thanks for some recommendation – Sydney Loteria Feb 11 '17 at 02:56

0 Answers0