Fix GH-22 (Support of SheetView in Excel5 Writer)
This commit is contained in:
parent
9f04d888a1
commit
9a29129ec7
|
@ -477,6 +477,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$this->_writeMsoDrawing();
|
||||
|
||||
$this->_writeWindow2();
|
||||
$this->_writePageLayoutView();
|
||||
$this->_writeZoom();
|
||||
if ($_phpSheet->getFreezePane()) {
|
||||
$this->_writePanes();
|
||||
|
@ -642,6 +643,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
{
|
||||
$this->_writeLabelSst($row, $col, $str, $xfIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a LABELSST record or a LABEL record. Which one depends on BIFF version
|
||||
* It differs from _writeString by the writing of rich text strings.
|
||||
|
@ -1279,15 +1281,15 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$grbit = $fDspFmla;
|
||||
$grbit |= $fDspGrid << 1;
|
||||
$grbit |= $fDspRwCol << 2;
|
||||
$grbit |= $fFrozen << 3;
|
||||
$grbit |= $fDspZeros << 4;
|
||||
$grbit |= $fDefaultHdr << 5;
|
||||
$grbit |= $fArabic << 6;
|
||||
$grbit |= $fDspRwCol << 2;
|
||||
$grbit |= $fFrozen << 3;
|
||||
$grbit |= $fDspZeros << 4;
|
||||
$grbit |= $fDefaultHdr << 5;
|
||||
$grbit |= $fArabic << 6;
|
||||
$grbit |= $fDspGuts << 7;
|
||||
$grbit |= $fFrozenNoSplit << 8;
|
||||
$grbit |= $fSelected << 9;
|
||||
$grbit |= $fPaged << 10;
|
||||
$grbit |= $fSelected << 9;
|
||||
$grbit |= $fPaged << 10;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvv", $grbit, $rwTop, $colLeft);
|
||||
|
@ -2238,10 +2240,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$record = 0x0012; // Record identifier
|
||||
$length = 0x0002; // Bytes to follow
|
||||
|
||||
$fLock = 1; // Worksheet is protected
|
||||
$fLock = 1; // Worksheet is protected
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("v", $fLock);
|
||||
$data = pack("v", $fLock);
|
||||
|
||||
$this->_append($header.$data);
|
||||
}
|
||||
|
@ -2951,4 +2953,33 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PLV Record
|
||||
*/
|
||||
private function _writePageLayoutView(){
|
||||
$record = 0x088B; // Record identifier
|
||||
$length = 0x0010; // Bytes to follow
|
||||
|
||||
$rt = 0x088B; // 2
|
||||
$grbitFrt = 0x0000; // 2
|
||||
$reserved = 0x0000000000000000; // 8
|
||||
$wScalvePLV = $this->_phpSheet->getSheetView()->getZoomScale(); // 2
|
||||
|
||||
// The options flags that comprise $grbit
|
||||
if($this->_phpSheet->getSheetView()->getView() == PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT){
|
||||
$fPageLayoutView = 1;
|
||||
} else {
|
||||
$fPageLayoutView = 0;
|
||||
}
|
||||
$fRulerVisible = 0;
|
||||
$fWhitespaceHidden = 0;
|
||||
|
||||
$grbit = $fPageLayoutView; // 2
|
||||
$grbit |= $fRulerVisible << 1;
|
||||
$grbit |= $fWhitespaceHidden << 3;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit);
|
||||
$this->_append($header . $data);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (C) 2006 - 2012 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** Error reporting */
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', TRUE);
|
||||
ini_set('display_startup_errors', TRUE);
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||
|
||||
/** Include PHPExcel */
|
||||
require_once '../Classes/PHPExcel.php';
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Set document properties
|
||||
echo date('H:i:s') , " Set document properties" , EOL;
|
||||
$objPHPExcel->getProperties()->setCreator("PHPOffice")
|
||||
->setLastModifiedBy("PHPOffice")
|
||||
->setTitle("PHPExcel Test Document")
|
||||
->setSubject("PHPExcel Test Document")
|
||||
->setDescription("Test document for PHPExcel, generated using PHP classes.")
|
||||
->setKeywords("Office PHPExcel php")
|
||||
->setCategory("Test result file");
|
||||
|
||||
|
||||
// Add some data
|
||||
echo date('H:i:s') , " Add some data" , EOL;
|
||||
$objPHPExcel->setActiveSheetIndex(0)
|
||||
->setCellValue('A1', 'Hello')
|
||||
->setCellValue('B2', 'world!');
|
||||
|
||||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
// Set the page layout view as page layout
|
||||
$objPHPExcel->getActiveSheet()->getSheetView()->setView(PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT);
|
||||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s') , " Write to Excel5 format" , EOL;
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||
$objWriter->save(str_replace('.php', '.xls', __FILE__));
|
||||
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
|
||||
|
||||
// Echo memory peak usage
|
||||
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
||||
// Echo done
|
||||
echo date('H:i:s') , " Done writing files" , EOL;
|
||||
echo 'Files have been created in ' , getcwd() , EOL;
|
|
@ -32,7 +32,7 @@ Fixed in develop branch:
|
|||
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
|
||||
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
|
||||
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't
|
||||
|
||||
- Bugfix: (Progi1984)Work item GH-22 - Sheet View in Excel5 Writer
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
BREAKING CHANGE! As part of the planned changes for handling array formulae in
|
||||
|
|
Loading…
Reference in New Issue