asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
544 stars 152 forks source link

Delete All Sheet Records #192

Open pardeepnadha opened 6 years ago

pardeepnadha commented 6 years ago

Dear

I want to remove all records exist in sheet. is there any way to do it? let me know.

Thanks

alavry commented 6 years ago

check out ListEntry.php, public function delete().

run a foreach on the sheet to delete each row except header

pardeepnadha commented 6 years ago

Thanks Its working but not properly please check my code below $listFeed = $worksheet->getListFeed(); foreach ($listFeed->getEntries() as $entry) { $entry->delete(); } when the loop is run it delete first row and then skip 2nd and then delete 3rd and skip 4th only deleting odd rows Is there any way to delete all rows once?

alavry commented 6 years ago

although it should theoretically work, i tried running it in my own script and got the same result as you. i tried debugging it, and think it's an issue/bug with the wrapper. i moved onto using the official google php api, which is on v4 and is much more powerful than what is available here. i recommend you do the same:

https://github.com/google/google-api-php-client https://developers.google.com/resources/api-libraries/documentation/sheets/v4/php/latest/