asimlqt / php-google-spreadsheet-client

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

How to loop all worksheets and update cell #138

Closed ByteToByte closed 8 years ago

ByteToByte commented 8 years ago

I try ... $spreadsheet = $spreadsheetFeed->getByTitle('table.xlsx'); $worksheetFeed = $spreadsheet->getWorksheetFeed(); $worksheets = $worksheetFeed->getEntries(); foreach($worksheets as $worksheet) { $worksheet->getListFeed(["sq" => "name=John", "reverse" => "true"]); } but i get unknown throw ex

How to correct loop syntax if don't know title's worksheet (You can loop over each worksheet using 'getEntries()') ? and update cell's with loop

If i use single by title $worksheet = $worksheetFeed->getByTitle('Sheet1'); then OK

Sry my eng poor. You understand me? Thx.

asimlqt commented 8 years ago

@Effectik I'm sorry I don't really understand what you're asking. Are you asking about how to correctly loop over the worksheets if you don't know what the title of the worksheet is?

If so the code sample above does look correct. Calling '$worksheetFeed->getEntries()' will return an array of Worksheets, so using foreach as you have above is right.

foreach ($worksheetFeed->getEntries() as $worksheet) {
    // $worksheet is a Worksheet object and you can call any methods on it, e.g. 'getListFeed()' and 'getCellFeed()'
}

Which line of code is throwing an exception? is it when you call getListFeed()?

ByteToByte commented 8 years ago

@asimlqt Thx man, but not working Yes. If i call getListFeed() and if not found item on first worksheet then i get exception

foreach ($worksheetFeed->getEntries() as $worksheet) {
     $worksheet->getListFeed(["sq" => "name=John", "reverse" => "true"]); throwing exception
}
ByteToByte commented 8 years ago

Invalid column name - this error. I fixed in my table.