Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete All Sheet Records #192

Open
pardeepnadha opened this issue May 29, 2018 · 3 comments
Open

Delete All Sheet Records #192

pardeepnadha opened this issue May 29, 2018 · 3 comments

Comments

@pardeepnadha
Copy link

Dear

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

Thanks

@alavry
Copy link

alavry commented May 30, 2018

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

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

@pardeepnadha
Copy link
Author

pardeepnadha commented May 30, 2018

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
Copy link

alavry commented May 30, 2018

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants