Google\Spreadsheet\WorksheetFeed::getByTitle PHP Method

getByTitle() public method

Get a worksheet by title (name)
public getByTitle ( string $title ) : Worksheet
$title string name of the worksheet
return Worksheet
    public function getByTitle($title)
    {
        foreach ($this->xml->entry as $entry) {
            if ($entry->title->__toString() == $title) {
                return new Worksheet($entry);
            }
        }
        throw new WorksheetNotFoundException();
    }

Usage Example

 public function testGetByTitle()
 {
     $xml = file_get_contents(__DIR__ . '/xml/worksheet-feed.xml');
     $worksheetFeed = new WorksheetFeed($xml);
     $this->assertTrue($worksheetFeed->getByTitle('Sheet1') instanceof Worksheet);
     $this->assertTrue(is_null($worksheetFeed->getByTitle('Sheet3')));
 }
All Usage Examples Of Google\Spreadsheet\WorksheetFeed::getByTitle