asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
543 stars 154 forks source link

Getting Last row with data #68

Closed silvios closed 8 years ago

silvios commented 9 years ago

Any idea how to get the last row with data from a worksheet?

I am having to manually insert rows basically setting it 1 column at a time because I have an offsetted header.

I have my own custom header before the data headers, that just tells the user viewing it if something is going on. (is script currently running, when was the data last updated, etc)

So the header does not start at row 1, which causes me not to be able to use the insert row method.... :/

Do you have any suggestions?

asimlqt commented 9 years ago

$worksheet->getListFeed()->getEntries() returns an array of all rows in the spreadsheet so it should be fairly easy to retrieve the last row if that's what you meant.

Unfortunately that's how Google Spreadsheet API works, it requires that the first row be the header row. You need to find another way of providing this user feedback e.g. using another worksheet specifically for this purpose or use the end of the header row after a blank column.

Hope that helps.