diff --git a/Classes/PHPExcel/Reader/Excel2003XML.php b/Classes/PHPExcel/Reader/Excel2003XML.php
index 1dd89d7e..ca7c1f51 100644
--- a/Classes/PHPExcel/Reader/Excel2003XML.php
+++ b/Classes/PHPExcel/Reader/Excel2003XML.php
@@ -206,6 +206,34 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
return $valid;
}
+ /**
+ * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
+ *
+ * @param string $pFilename
+ * @throws Exception
+ */
+ public function listWorksheetNames($pFilename)
+ {
+ // Check if file exists
+ if (!file_exists($pFilename)) {
+ throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
+ }
+
+ $worksheetNames = array();
+
+ $xml = simplexml_load_file($pFilename);
+ $namespaces = $xml->getNamespaces(true);
+
+ $xml_ss = $xml->children($namespaces['ss']);
+ foreach($xml_ss->Worksheet as $worksheet) {
+ $worksheet_ss = $worksheet->attributes($namespaces['ss']);
+ $worksheetNames[] = $worksheet_ss['Name'];
+ }
+
+ return $worksheetNames;
+ }
+
+
/**
* Loads PHPExcel from file
*
@@ -512,9 +540,10 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
// echo '
';
$worksheetID = 0;
- foreach($xml->Worksheet as $worksheet) {
+ $xml_ss = $xml->children($namespaces['ss']);
+ foreach($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
-// echo $worksheet_ss['Name'],'
';
+
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
(!in_array($worksheet_ss['Name'], $this->_loadSheetsOnly))) {
continue;
diff --git a/changelog.txt b/changelog.txt
index a81585f9..8219a0cb 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -26,7 +26,7 @@
Fixed in SVN:
- Feature: (MBaker) Provide option to use PCLZip as an alternative to ZipArchive.
This allows the writing of Excel2007 files, even without ZipArchive enabled (it does require zlib), or when php_zip is one of the buggy PHP 5.2.6 or 5.2.8 versions
-- Feature: (MBaker) Work item 14979 - Added listWorksheetNames() method to Excel2007, Excel5, OOCalc and Gnumeric Readers, allowing a user to extract a list of worksheet names from a file without parsing/loading the whole file.
+- Feature: (MBaker) Work item 14979 - Added listWorksheetNames() method to Readers that support multiple worksheets in a workbook, allowing a user to extract a list of all the worksheet names from a file without parsing/loading the whole file.
- Bugfix: (MBaker) Work item 14888 - Simple =IF() formula disappears
- Bugfix: (MBaker) Work item 14898 - PHP Warning: preg_match(): Compilation failed: PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X
- Bugfix: (MBaker) Work item 14901 - VLOOKUP choking on parameters in PHPExcel.1.7.5/PHPExcel_Writer_Excel2007