From da8bcea5b9ee931779ae42726fe92b4ba0161695 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 2 Sep 2010 23:01:12 +0000 Subject: [PATCH] AddedFeature: Work item 8769 - Implement Gnumeric File Format Added Named Range handling to Gnumeric Reader git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@60300 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Reader/Gnumeric.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Reader/Gnumeric.php b/Classes/PHPExcel/Reader/Gnumeric.php index 99afe8a..ccfc4e1 100644 --- a/Classes/PHPExcel/Reader/Gnumeric.php +++ b/Classes/PHPExcel/Reader/Gnumeric.php @@ -338,7 +338,6 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader } } - $worksheetID = 0; foreach($gnmXML->Sheets->Sheet as $sheet) { $worksheetName = (string) $sheet->Name; @@ -414,6 +413,21 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader $worksheetID++; } + // Loop through definedNames + if (isset($gnmXML->Names)) { + foreach($gnmXML->Names->Name as $namedRange) { + $name = (string) $namedRange->name; + $range = (string) $namedRange->value; + + $range = explode('!',$range); + $range[0] = trim($range[0],"'");; + if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { + $extractedRange = str_replace('$', '', $range[1]); + $objPHPExcel->addNamedRange( new PHPExcel_NamedRange($name, $worksheet, $extractedRange) ); + } + } + } + // Return return $objPHPExcel;