diff --git a/Classes/PHPExcel/Worksheet/SheetView.php b/Classes/PHPExcel/Worksheet/SheetView.php index 418e45a1..e76cec5e 100644 --- a/Classes/PHPExcel/Worksheet/SheetView.php +++ b/Classes/PHPExcel/Worksheet/SheetView.php @@ -35,6 +35,11 @@ */ class PHPExcel_Worksheet_SheetView { + + /* Fill types */ + const VIEW_PAGE_LAYOUT = 'pageLayout'; + const VIEW_PAGE_BREAK_PREVIEW = 'pageBreakPreview'; + /** * ZoomScale * @@ -53,6 +58,15 @@ class PHPExcel_Worksheet_SheetView */ private $_zoomScaleNormal = 100; + /** + * View + * + * Valid values range from 10 to 400. + * + * @var string + */ + private $_view = false; + /** * Create a new PHPExcel_Worksheet_SheetView */ @@ -116,6 +130,34 @@ class PHPExcel_Worksheet_SheetView return $this; } + /** + * Get View + * + * @return int + */ + public function getView() { + return $this->_view; + } + + /** + * Set View + * + * Valid values range from 10 to 400. + * + * @param string $pValue + * @throws Exception + * @return PHPExcel_Worksheet_SheetView + */ + public function setView($pValue = false) { + // Microsoft Office Excel 2007 only allows setting a view 'pageLayout' or 'pageBreakPreview' via the user interface, + if (($pValue === false) || in_array($pValue, array(self::VIEW_PAGE_LAYOUT, self::VIEW_PAGE_BREAK_PREVIEW))) { + $this->_view = $pValue; + } else { + throw new Exception("Invalid view."); + } + return $this; + } + /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index b97648db..036f4b73 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -218,6 +218,11 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $objWriter->writeAttribute('zoomScaleNormal', $pSheet->getSheetView()->getZoomScaleNormal()); } + // View + if ($pSheet->getSheetView()->getView() != false) { + $objWriter->writeAttribute('view', $pSheet->getSheetView()->getView()); + } + // Gridlines if ($pSheet->getShowGridlines()) { $objWriter->writeAttribute('showGridLines', 'true');