You are here

public function PHPExcel_Reader_Excel2003XML::listWorksheetNames in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php \PHPExcel_Reader_Excel2003XML::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/Excel2003XML.php, line 128

Class

PHPExcel_Reader_Excel2003XML
PHPExcel_Reader_Excel2003XML

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.");
  }
  if (!$this
    ->canRead($pFilename)) {
    throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
  }
  $worksheetNames = array();
  $xml = simplexml_load_string($this
    ->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
  $namespaces = $xml
    ->getNamespaces(true);
  $xml_ss = $xml
    ->children($namespaces['ss']);
  foreach ($xml_ss->Worksheet as $worksheet) {
    $worksheet_ss = $worksheet
      ->attributes($namespaces['ss']);
    $worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet);
  }
  return $worksheetNames;
}