You are here

public function PHPExcel_Reader_Excel5::listWorksheetNames in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::listWorksheetNames()

* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * *

Parameters

string $pFilename: * @throws PHPExcel_Reader_Exception

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php, line 465

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

public function listWorksheetNames($pFilename) {

  // Check if file exists
  if (!file_exists($pFilename)) {
    throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
  }
  $worksheetNames = array();

  // Read the OLE file
  $this
    ->_loadOLE($pFilename);

  // total byte size of Excel data (workbook global substream + sheet substreams)
  $this->_dataSize = strlen($this->_data);
  $this->_pos = 0;
  $this->_sheets = array();

  // Parse Workbook Global Substream
  while ($this->_pos < $this->_dataSize) {
    $code = self::_GetInt2d($this->_data, $this->_pos);
    switch ($code) {
      case self::XLS_Type_BOF:
        $this
          ->_readBof();
        break;
      case self::XLS_Type_SHEET:
        $this
          ->_readSheet();
        break;
      case self::XLS_Type_EOF:
        $this
          ->_readDefault();
        break 2;
      default:
        $this
          ->_readDefault();
        break;
    }
  }
  foreach ($this->_sheets as $sheet) {
    if ($sheet['sheetType'] != 0x0) {

      // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
      continue;
    }
    $worksheetNames[] = $sheet['name'];
  }
  return $worksheetNames;
}