public function PHPExcel_Reader_Excel2003XML::listWorksheetInfo in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php \PHPExcel_Reader_Excel2003XML::listWorksheetInfo()
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) * *
Parameters
string $pFilename: * @throws PHPExcel_Reader_Exception
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel2003XML.php, line 159
Class
- PHPExcel_Reader_Excel2003XML
- PHPExcel_Reader_Excel2003XML
Code
public function listWorksheetInfo($pFilename) {
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetInfo = array();
$xml = simplexml_load_string($this
->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespaces = $xml
->getNamespaces(true);
$worksheetID = 1;
$xml_ss = $xml
->children($namespaces['ss']);
foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet
->attributes($namespaces['ss']);
$tmpInfo = array();
$tmpInfo['worksheetName'] = '';
$tmpInfo['lastColumnLetter'] = 'A';
$tmpInfo['lastColumnIndex'] = 0;
$tmpInfo['totalRows'] = 0;
$tmpInfo['totalColumns'] = 0;
if (isset($worksheet_ss['Name'])) {
$tmpInfo['worksheetName'] = (string) $worksheet_ss['Name'];
}
else {
$tmpInfo['worksheetName'] = "Worksheet_{$worksheetID}";
}
if (isset($worksheet->Table->Row)) {
$rowIndex = 0;
foreach ($worksheet->Table->Row as $rowData) {
$columnIndex = 0;
$rowHasData = false;
foreach ($rowData->Cell as $cell) {
if (isset($cell->Data)) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
$rowHasData = true;
}
++$columnIndex;
}
++$rowIndex;
if ($rowHasData) {
$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
}
}
}
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
$worksheetInfo[] = $tmpInfo;
++$worksheetID;
}
return $worksheetInfo;
}