Merge pull request #21 from k1LoW/sheetview_view
Support SheetView `view` param
This commit is contained in:
commit
f830c0f3a8
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue