You are here

public function PHPExcel_Writer_HTML::generateNavigation in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php \PHPExcel_Writer_HTML::generateNavigation()

* Generate sheet tabs * *

Return value

string * @throws PHPExcel_Writer_Exception

1 call to PHPExcel_Writer_HTML::generateNavigation()
PHPExcel_Writer_HTML::save in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php
* Save PHPExcel to file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php, line 475

Class

PHPExcel_Writer_HTML
PHPExcel_Writer_HTML

Code

public function generateNavigation() {

  // PHPExcel object known?
  if (is_null($this->_phpExcel)) {
    throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
  }

  // Fetch sheets
  $sheets = array();
  if (is_null($this->_sheetIndex)) {
    $sheets = $this->_phpExcel
      ->getAllSheets();
  }
  else {
    $sheets[] = $this->_phpExcel
      ->getSheet($this->_sheetIndex);
  }

  // Construct HTML
  $html = '';

  // Only if there are more than 1 sheets
  if (count($sheets) > 1) {

    // Loop all sheets
    $sheetId = 0;
    $html .= '<ul class="navigation">' . PHP_EOL;
    foreach ($sheets as $sheet) {
      $html .= '  <li class="sheet' . $sheetId . '"><a href="#sheet' . $sheetId . '">' . $sheet
        ->getTitle() . '</a></li>' . PHP_EOL;
      ++$sheetId;
    }
    $html .= '</ul>' . PHP_EOL;
  }
  return $html;
}