add read/write page-break-preview in Excel5

This commit is contained in:
karak 2012-11-22 14:57:47 +09:00
parent c9610c936f
commit 0fd8af9cd8
2 changed files with 39 additions and 3 deletions

View File

@ -3995,6 +3995,22 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// offset: 0; size: 2; option flags // offset: 0; size: 2; option flags
$options = self::_GetInt2d($recordData, 0); $options = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to first visible row
$firstVisibleRow = self::_GetInt2d($recordData, 2);
// offset: 4; size: 2; index to first visible colum
$firstVisibleColumn = self::_GetInt2d($recordData, 4);
if ($this->_version === self::XLS_BIFF8) {
// offset: 8; size: 2; not used
// offset: 10; size: 2; cached magnification factor in page break preview (in percent); 0 = Default (60%)
// offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%)
// offset: 14; size: 4; not used
$zoomscaleInPageBreakPreview = self::_GetInt2d($recordData, 10);
if ($zoomscaleInPageBreakPreview === 0) $zoomscaleInPageBreakPreview = 60;
$zoomscaleInNormalView = self::_GetInt2d($recordData, 12);
if ($zoomscaleInNormalView === 0) $zoomscaleInNormalView = 100;
}
// bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines // bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines
$showGridlines = (bool) ((0x0002 & $options) >> 1); $showGridlines = (bool) ((0x0002 & $options) >> 1);
$this->_phpSheet->setShowGridlines($showGridlines); $this->_phpSheet->setShowGridlines($showGridlines);
@ -4014,6 +4030,23 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
if ($isActive) { if ($isActive) {
$this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet)); $this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet));
} }
// bit: 11; mask: 0x0800; 0 = normal view, 1 = page break view
$isPageBreakPreview = (bool) ((0x0800 & $options) >> 11);
//FIXME: set $firstVisibleRow and $firstVisibleColumn
if ($this->_phpSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT) {
//NOTE: this setting is inferior to page layout view(Excel2007-)
$view = $isPageBreakPreview? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW :
PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL;
$this->_phpSheet->getSheetView()->setView($view);
if ($this->_version === self::XLS_BIFF8) {
$zoomScale = $isPageBreakPreview? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView;
$this->_phpSheet->getSheetView()->setZoomScale($zoomScale);
$this->_phpSheet->getSheetView()->setZoomScaleNormal($zoomscaleInNormalView);
}
}
} }
/** /**

View File

@ -1278,6 +1278,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// no support in PHPExcel for selected sheet, therefore sheet is only selected if it is the active sheet // no support in PHPExcel for selected sheet, therefore sheet is only selected if it is the active sheet
$fSelected = ($this->_phpSheet === $this->_phpSheet->getParent()->getActiveSheet()) ? 1 : 0; $fSelected = ($this->_phpSheet === $this->_phpSheet->getParent()->getActiveSheet()) ? 1 : 0;
$fPaged = 1; // 2 $fPaged = 1; // 2
$fPageBreakPreview = $this->_phpSheet->getSheetView()->getView() === PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW;
$grbit = $fDspFmla; $grbit = $fDspFmla;
$grbit |= $fDspGrid << 1; $grbit |= $fDspGrid << 1;
@ -1290,14 +1291,16 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$grbit |= $fFrozenNoSplit << 8; $grbit |= $fFrozenNoSplit << 8;
$grbit |= $fSelected << 9; $grbit |= $fSelected << 9;
$grbit |= $fPaged << 10; $grbit |= $fPaged << 10;
$grbit |= $fPageBreakPreview << 11;
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvv", $grbit, $rwTop, $colLeft); $data = pack("vvv", $grbit, $rwTop, $colLeft);
// FIXME !!! // FIXME !!!
$rgbHdr = 0x0040; // Row/column heading and gridline color index $rgbHdr = 0x0040; // Row/column heading and gridline color index
$zoom_factor_page_break = 0x0000; $zoom_factor_page_break = ($fPageBreakPreview? $this->_phpSheet->getSheetView()->getZoomScale() : 0x0000);
$zoom_factor_normal = 0x0000; $zoom_factor_normal = $this->_phpSheet->getSheetView()->getZoomScaleNormal();
$data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000); $data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
$this->_append($header.$data); $this->_append($header.$data);