Support SheetView view param

This commit is contained in:
k1LoW 2012-08-09 10:13:05 +09:00
parent c770117193
commit d24e640801
2 changed files with 47 additions and 0 deletions

View File

@ -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.
*/

View File

@ -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');