From 1586444ba91735fbcc7d2fc811d77a0941d51081 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 5 Sep 2010 21:13:03 +0000 Subject: [PATCH] Feature: Work item 8769 - Implement Gnumeric File Format Print margins git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@60426 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Reader/Gnumeric.php | 47 +++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/Classes/PHPExcel/Reader/Gnumeric.php b/Classes/PHPExcel/Reader/Gnumeric.php index 335c2b2f..b1a86e7b 100644 --- a/Classes/PHPExcel/Reader/Gnumeric.php +++ b/Classes/PHPExcel/Reader/Gnumeric.php @@ -248,7 +248,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader $gFileData = $this->_gzfileGetContents($pFilename); // echo '
';
-//		echo htmlentities($gFileData);
+//		echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
 //		echo '

'; // $xml = simplexml_load_string($gFileData); @@ -344,6 +344,39 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader $objPHPExcel->setActiveSheetIndex($worksheetID); $objPHPExcel->getActiveSheet()->setTitle($worksheetName); + if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { + if (isset($sheet->PrintInformation->Margins)) { + foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) { + $marginAttributes = $margin->attributes(); + switch($marginAttributes['PrefUnit']) { + case 'mm' : + $marginSize = intval($marginAttributes['Points']) / 100; + break; + } + switch($key) { + case 'top' : + $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); + break; + case 'bottom' : + $objPHPExcel->getActiveSheet()->getPageMargins()->setBottom($marginSize); + break; + case 'left' : + $objPHPExcel->getActiveSheet()->getPageMargins()->setLeft($marginSize); + break; + case 'right' : + $objPHPExcel->getActiveSheet()->getPageMargins()->setRight($marginSize); + break; + case 'header' : + $objPHPExcel->getActiveSheet()->getPageMargins()->setHeader($marginSize); + break; + case 'footer' : + $objPHPExcel->getActiveSheet()->getPageMargins()->setFooter($marginSize); + break; + } + } + } + } + foreach($sheet->Cells->Cell as $cell) { $cellAttributes = $cell->attributes(); $row = (int) $cellAttributes->Row + 1; @@ -617,6 +650,10 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader $styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN; } } + if (isset($styleRegion->Style->HyperLink)) { + // TO DO + $hyperlink = $styleRegion->Style->HyperLink->attributes(); + } } // var_dump($styleArray); // echo '
'; @@ -625,8 +662,8 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader } } - // Column Widths - if (isset($sheet->Cols)) { + if ((!$this->_readDataOnly) && (isset($sheet->Cols))) { + // Column Widths $columnAttributes = $sheet->Cols->attributes(); $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; $c = 0; @@ -654,8 +691,8 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader } } - // Row Heights - if (isset($sheet->Rows)) { + if ((!$this->_readDataOnly) && (isset($sheet->Rows))) { + // Row Heights $rowAttributes = $sheet->Rows->attributes(); $defaultHeight = $rowAttributes['DefaultSizePts']; $r = 0;