mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 16:56:03 +03:00
Feature: Work item 14979 - Added listWorksheetNames() method to OOCalc and Gnumeric Readers
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@66079 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
e3a01db2a9
commit
14cc952323
@ -222,6 +222,36 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.");
|
||||
}
|
||||
|
||||
$gFileData = $this->_gzfileGetContents($pFilename);
|
||||
|
||||
$xml = simplexml_load_string($gFileData);
|
||||
$namespacesMeta = $xml->getNamespaces(true);
|
||||
|
||||
$gnmXML = $xml->children($namespacesMeta['gnm']);
|
||||
|
||||
$worksheetNames = array();
|
||||
|
||||
foreach($gnmXML->Sheets->Sheet as $sheet) {
|
||||
$worksheetNames[] = (string) $sheet->Name;
|
||||
}
|
||||
|
||||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
|
@ -186,6 +186,42 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
|
||||
$xml = simplexml_load_string($zip->getFromName("content.xml"));
|
||||
$namespacesContent = $xml->getNamespaces(true);
|
||||
|
||||
$workbook = $xml->children($namespacesContent['office']);
|
||||
foreach($workbook->body->spreadsheet as $workbookData) {
|
||||
$workbookData = $workbookData->children($namespacesContent['table']);
|
||||
foreach($workbookData->table as $worksheetDataSet) {
|
||||
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
|
||||
|
||||
$worksheetNames[] = $worksheetDataAttributes['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $worksheetNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
|
@ -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 and Excel5 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 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.
|
||||
- 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
|
||||
|
Loading…
Reference in New Issue
Block a user