addWorksheet() публичный Метод

Add a new worksheet to this spreadsheet
public addWorksheet ( string $title, integer $rowCount = 100, integer $colCount = 10 ) : Worksheet
$title string
$rowCount integer default is 100
$colCount integer default is 10
Результат Worksheet
 public function testAddWorksheet()
 {
     $this->setServiceRequest('worksheet.xml');
     $xml = file_get_contents(__DIR__ . '/xml/spreadsheet.xml');
     $spreadsheet = new Spreadsheet(new SimpleXMLElement($xml));
     $this->assertTrue($spreadsheet->addWorksheet('Sheet 3') instanceof Worksheet);
 }
 public function testAddWorksheet()
 {
     $this->setServiceRequest("worksheet.xml");
     $spreadsheet = new Spreadsheet($this->getSimpleXMLElement("spreadsheet"));
     $this->assertTrue($spreadsheet->addWorksheet("Sheet 3") instanceof Worksheet);
 }
Пример #3
0
 protected function _get_new_worksheet($title, \Google\Spreadsheet\Spreadsheet &$spreadsheet, \Google\Spreadsheet\WorksheetFeed &$worksheet_feed)
 {
     $spreadsheet->addWorksheet($title);
     $worksheet_feed = $spreadsheet->getWorksheets();
     # delete auto generated worksheets
     $_auto_worksheet_names = ['Sheet1', 'Sheet2', 'Sheet3', 'Sheet4'];
     $auto_worksheet_names = [];
     foreach ($_auto_worksheet_names as $_auto_worksheet_name) {
         if ($title != $_auto_worksheet_name) {
             $auto_worksheet_names[] = $_auto_worksheet_name;
         }
     }
     foreach ($auto_worksheet_names as $auto_worksheet_name) {
         $temp_worksheet = $worksheet_feed->getByTitle($auto_worksheet_name);
         if ($temp_worksheet) {
             $temp_worksheet->delete();
         }
     }
     $worksheet = $worksheet_feed->getByTitle($title);
     if (!$worksheet) {
         throw new HelperException('error creating worksheet');
     }
     return $worksheet;
 }