Performance improvements by removing tests against BIFF version... especially as we only save as BIFF8 now, BIFF5 having been discarded some releases ago
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@74466 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
48b2fb8e99
commit
c792f053b5
|
@ -107,7 +107,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
|||
public function __construct(PHPExcel $phpExcel) {
|
||||
$this->_phpExcel = $phpExcel;
|
||||
|
||||
$this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version);
|
||||
$this->_parser = new PHPExcel_Writer_Excel5_Parser();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,18 +130,18 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
|||
$this->_colors = array();
|
||||
|
||||
// Initialise workbook writer
|
||||
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version,
|
||||
$this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
|
||||
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel,
|
||||
$this->_str_total, $this->_str_unique, $this->_str_table,
|
||||
$this->_colors, $this->_parser);
|
||||
|
||||
// Initialise worksheet writers
|
||||
$countSheets = $this->_phpExcel->getSheetCount();
|
||||
for ($i = 0; $i < $countSheets; ++$i) {
|
||||
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version,
|
||||
$this->_str_total, $this->_str_unique,
|
||||
$this->_str_table, $this->_colors,
|
||||
$this->_parser,
|
||||
$this->_preCalculateFormulas,
|
||||
$this->_phpExcel->getSheet($i));
|
||||
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique,
|
||||
$this->_str_table, $this->_colors,
|
||||
$this->_parser,
|
||||
$this->_preCalculateFormulas,
|
||||
$this->_phpExcel->getSheet($i));
|
||||
}
|
||||
|
||||
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
|
||||
|
@ -161,7 +161,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
|
|||
}
|
||||
|
||||
// initialize OLE file
|
||||
$workbookStreamName = ($this->_BIFF_version == 0x0600) ? 'Workbook' : 'Book';
|
||||
$workbookStreamName = 'Workbook';
|
||||
$OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
|
||||
|
||||
// Write the worksheet streams before the global workbook stream,
|
||||
|
|
|
@ -69,12 +69,6 @@
|
|||
*/
|
||||
class PHPExcel_Writer_Excel5_BIFFwriter
|
||||
{
|
||||
/**
|
||||
* The BIFF/Excel version (5).
|
||||
* @var integer
|
||||
*/
|
||||
public $_BIFF_version = 0x0500;
|
||||
|
||||
/**
|
||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||
* @var integer
|
||||
|
@ -128,8 +122,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$byte_order = 1; // Big Endian
|
||||
} else {
|
||||
// Give up. I'll fix this in a later version.
|
||||
throw new Exception("Required floating point format ".
|
||||
"not supported on this platform.");
|
||||
throw new Exception("Required floating point format not supported on this platform.");
|
||||
}
|
||||
self::$_byte_order = $byte_order;
|
||||
}
|
||||
|
@ -179,24 +172,15 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
|||
function _storeBof($type)
|
||||
{
|
||||
$record = 0x0809; // Record identifier
|
||||
$length = 0x0010;
|
||||
|
||||
// According to the SDK $build and $year should be set to zero.
|
||||
// However, this throws a warning in Excel 5. So, use magic numbers.
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$length = 0x0008;
|
||||
$unknown = '';
|
||||
$build = 0x096C;
|
||||
$year = 0x07C9;
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$length = 0x0010;
|
||||
// by inspection of real files, MS Office Excel 2007 writes the following
|
||||
$unknown = pack("VV", 0x000100D1, 0x00000406);
|
||||
|
||||
// by inspection of real files, MS Office Excel 2007 writes the following
|
||||
$unknown = pack("VV", 0x000100D1, 0x00000406);
|
||||
$build = 0x0DBB;
|
||||
$year = 0x07CC;
|
||||
|
||||
$build = 0x0DBB;
|
||||
$year = 0x07CC;
|
||||
}
|
||||
$version = $this->_BIFF_version;
|
||||
$version = 0x0600;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvvv", $version, $type, $build, $year);
|
||||
|
@ -212,6 +196,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
|
|||
{
|
||||
$record = 0x000A; // Record identifier
|
||||
$length = 0x0000; // Number of bytes to follow
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$this->_append($header);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,6 @@
|
|||
*/
|
||||
class PHPExcel_Writer_Excel5_Font
|
||||
{
|
||||
/**
|
||||
* BIFF version
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_BIFFVersion;
|
||||
|
||||
/**
|
||||
* Color index
|
||||
*
|
||||
|
@ -63,7 +56,6 @@ class PHPExcel_Writer_Excel5_Font
|
|||
*/
|
||||
public function __construct(PHPExcel_Style_Font $font = null)
|
||||
{
|
||||
$this->_BIFFVersion = 0x0600;
|
||||
$this->_colorIndex = 0x7FFF;
|
||||
$this->_font = $font;
|
||||
}
|
||||
|
@ -115,34 +107,18 @@ class PHPExcel_Writer_Excel5_Font
|
|||
$grbit |= 0x20;
|
||||
}
|
||||
|
||||
if ($this->_BIFFVersion == 0x0500) {
|
||||
$data = pack("vvvvvCCCCC",
|
||||
$this->_font->getSize() * 20,
|
||||
$grbit,
|
||||
$icv,
|
||||
$this->_mapBold($this->_font->getBold()),
|
||||
$sss,
|
||||
$this->_mapUnderline($this->_font->getUnderline()),
|
||||
$bFamily,
|
||||
$bCharSet,
|
||||
$reserved,
|
||||
strlen($this->_font->getName())
|
||||
);
|
||||
$data .= $this->_font->getName();
|
||||
} elseif ($this->_BIFFVersion == 0x0600) {
|
||||
$data = pack("vvvvvCCCC",
|
||||
$this->_font->getSize() * 20,
|
||||
$grbit,
|
||||
$icv,
|
||||
$this->_mapBold($this->_font->getBold()),
|
||||
$sss,
|
||||
$this->_mapUnderline($this->_font->getUnderline()),
|
||||
$bFamily,
|
||||
$bCharSet,
|
||||
$reserved
|
||||
);
|
||||
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
|
||||
}
|
||||
$data = pack("vvvvvCCCC",
|
||||
$this->_font->getSize() * 20,
|
||||
$grbit,
|
||||
$icv,
|
||||
$this->_mapBold($this->_font->getBold()),
|
||||
$sss,
|
||||
$this->_mapUnderline($this->_font->getUnderline()),
|
||||
$bFamily,
|
||||
$bCharSet,
|
||||
$reserved
|
||||
);
|
||||
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
|
||||
|
||||
$length = strlen($data);
|
||||
$header = pack("vv", $record, $length);
|
||||
|
@ -150,16 +126,6 @@ class PHPExcel_Writer_Excel5_Font
|
|||
return($header . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set BIFF version
|
||||
*
|
||||
* @param int $BIFFVersion
|
||||
*/
|
||||
public function setBIFFVersion($BIFFVersion)
|
||||
{
|
||||
$this->_BIFFVersion = $BIFFVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map to BIFF5-BIFF8 codes for bold
|
||||
*
|
||||
|
|
|
@ -115,22 +115,15 @@ class PHPExcel_Writer_Excel5_Parser
|
|||
*/
|
||||
public $_references;
|
||||
|
||||
/**
|
||||
* The BIFF version for the workbook
|
||||
* @var integer
|
||||
*/
|
||||
public $_BIFF_version;
|
||||
|
||||
/**
|
||||
* The class constructor
|
||||
*
|
||||
* @param integer $byte_order The byte order (Little endian or Big endian) of the architecture
|
||||
* (optional). 1 => big endian, 0 (default) little endian.
|
||||
*/
|
||||
public function __construct($biff_version)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_current_char = 0;
|
||||
$this->_BIFF_version = $biff_version;
|
||||
$this->_current_token = ''; // The token we are working on.
|
||||
$this->_formula = ''; // The formula to parse.
|
||||
$this->_lookahead = ''; // The character ahead of the current char.
|
||||
|
@ -610,11 +603,7 @@ class PHPExcel_Writer_Excel5_Parser
|
|||
throw new Exception("String is too long");
|
||||
}
|
||||
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string;
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string);
|
||||
}
|
||||
return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -695,11 +684,7 @@ class PHPExcel_Writer_Excel5_Parser
|
|||
list($ext_ref, $range) = explode('!', $token);
|
||||
|
||||
// Convert the external reference part (different for BIFF8)
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$ext_ref = $this->_packExtRef($ext_ref);
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$ext_ref = $this->_getRefIndex($ext_ref);
|
||||
}
|
||||
$ext_ref = $this->_getRefIndex($ext_ref);
|
||||
|
||||
// Split the range into 2 cell refs
|
||||
list($cell1, $cell2) = explode(':', $range);
|
||||
|
@ -774,11 +759,7 @@ class PHPExcel_Writer_Excel5_Parser
|
|||
list($ext_ref, $cell) = explode('!', $cell);
|
||||
|
||||
// Convert the external reference part (different for BIFF8)
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$ext_ref = $this->_packExtRef($ext_ref);
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$ext_ref = $this->_getRefIndex($ext_ref);
|
||||
}
|
||||
$ext_ref = $this->_getRefIndex($ext_ref);
|
||||
|
||||
// Convert the cell reference part
|
||||
list($row, $col) = $this->_cellToPackedRowcol($cell);
|
||||
|
@ -973,16 +954,11 @@ class PHPExcel_Writer_Excel5_Parser
|
|||
}
|
||||
|
||||
// Set the high bits to indicate if row or col are relative.
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$row |= $col_rel << 14;
|
||||
$row |= $row_rel << 15;
|
||||
$col = pack('C', $col);
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$col |= $col_rel << 14;
|
||||
$col |= $row_rel << 15;
|
||||
$col = pack('v', $col);
|
||||
}
|
||||
$row = pack('v', $row);
|
||||
$col |= $col_rel << 14;
|
||||
$col |= $row_rel << 15;
|
||||
$col = pack('v', $col);
|
||||
|
||||
$row = pack('v', $row);
|
||||
|
||||
return array($row, $col);
|
||||
}
|
||||
|
@ -1016,19 +992,13 @@ class PHPExcel_Writer_Excel5_Parser
|
|||
}
|
||||
|
||||
// Set the high bits to indicate if rows are relative.
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$row1 |= $row1_rel << 14; // FIXME: probably a bug
|
||||
$row2 |= $row2_rel << 15;
|
||||
$col1 = pack('C', $col1);
|
||||
$col2 = pack('C', $col2);
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$col1 |= $row1_rel << 15;
|
||||
$col2 |= $row2_rel << 15;
|
||||
$col1 = pack('v', $col1);
|
||||
$col2 = pack('v', $col2);
|
||||
}
|
||||
$row1 = pack('v', $row1);
|
||||
$row2 = pack('v', $row2);
|
||||
$col1 |= $row1_rel << 15;
|
||||
$col2 |= $row2_rel << 15;
|
||||
$col1 = pack('v', $col1);
|
||||
$col2 = pack('v', $col2);
|
||||
|
||||
$row1 = pack('v', $row1);
|
||||
$row2 = pack('v', $row2);
|
||||
|
||||
return array($row1, $col1, $row2, $col2);
|
||||
}
|
||||
|
|
|
@ -194,16 +194,14 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
* Class constructor
|
||||
*
|
||||
* @param PHPExcel $phpExcel The Workbook
|
||||
* @param int $BIFF_verions BIFF version
|
||||
* @param int $str_total Total number of strings
|
||||
* @param int $str_unique Total number of unique strings
|
||||
* @param array $str_table
|
||||
* @param mixed $parser The formula parser created for the Workbook
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel = null, $BIFF_version = 0x0600,
|
||||
&$str_total,
|
||||
&$str_unique, &$str_table, &$colors, $parser
|
||||
)
|
||||
public function __construct(PHPExcel $phpExcel = null,
|
||||
&$str_total, &$str_unique, &$str_table, &$colors,
|
||||
$parser )
|
||||
{
|
||||
// It needs to call its parent's constructor explicitly
|
||||
parent::__construct();
|
||||
|
@ -211,7 +209,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$this->_parser = $parser;
|
||||
$this->_biffsize = 0;
|
||||
$this->_palette = array();
|
||||
$this->_codepage = 0x04E4; // FIXME: should change for BIFF8
|
||||
$this->_country_code = -1;
|
||||
|
||||
$this->_str_total = &$str_total;
|
||||
|
@ -222,12 +219,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$this->_phpExcel = $phpExcel;
|
||||
|
||||
if ($BIFF_version == 0x0600) {
|
||||
$this->_BIFF_version = 0x0600;
|
||||
// change BIFFwriter limit for CONTINUE records
|
||||
$this->_limit = 8224;
|
||||
$this->_codepage = 0x04B0;
|
||||
}
|
||||
// set BIFFwriter limit for CONTINUE records
|
||||
$this->_limit = 8224;
|
||||
$this->_codepage = 0x04B0;
|
||||
|
||||
// Add empty sheets and Build color cache
|
||||
$countSheets = $phpExcel->getSheetCount();
|
||||
|
@ -236,12 +230,10 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$this->_parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser
|
||||
|
||||
// for BIFF8
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$supbook_index = 0x00;
|
||||
$ref = pack('vvv', $supbook_index, $i, $i);
|
||||
$this->_parser->_references[] = $ref; // Register reference with parser
|
||||
}
|
||||
$supbook_index = 0x00;
|
||||
$ref = pack('vvv', $supbook_index, $i, $i);
|
||||
$this->_parser->_references[] = $ref; // Register reference with parser
|
||||
|
||||
// Sheet tab colors?
|
||||
if ($phpSheet->isTabColorSet()) {
|
||||
$this->_addColor($phpSheet->getTabColor()->getRGB());
|
||||
|
@ -260,7 +252,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
public function addXfWriter($style, $isStyleXf = false)
|
||||
{
|
||||
$xfWriter = new PHPExcel_Writer_Excel5_Xf($style);
|
||||
$xfWriter->setBIFFVersion($this->_BIFF_version);
|
||||
$xfWriter->setIsStyleXf($isStyleXf);
|
||||
|
||||
// Add the font if not already added
|
||||
|
@ -273,7 +264,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1;
|
||||
|
||||
$fontWriter = new PHPExcel_Writer_Excel5_Font($style->getFont());
|
||||
$fontWriter->setBIFFVersion($this->_BIFF_version);
|
||||
$fontWriter->setColorIndex($this->_addColor($style->getFont()->getColor()->getRGB()));
|
||||
$this->_fontWriters[] = $fontWriter;
|
||||
|
||||
|
@ -433,16 +423,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
// Add part 1 of the Workbook globals, what goes before the SHEET records
|
||||
$this->_storeBof(0x0005);
|
||||
$this->_writeCodepage();
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$this->_writeWindow1();
|
||||
}
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$this->_writeExterns(); // For print area and repeat rows
|
||||
$this->_writeNames(); // For print area and repeat rows
|
||||
}
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$this->_writeWindow1();
|
||||
}
|
||||
$this->_writeWindow1();
|
||||
|
||||
$this->_writeDatemode();
|
||||
$this->_writeAllFonts();
|
||||
$this->_writeAllNumFormats();
|
||||
|
@ -457,15 +439,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
}
|
||||
$part3 .= $this->_writeRecalcId();
|
||||
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$part3 .= $this->_writeSupbookInternal();
|
||||
/* TODO: store external SUPBOOK records and XCT and CRN records
|
||||
in case of external references for BIFF8 */
|
||||
$part3 .= $this->_writeExternsheetBiff8();
|
||||
$part3 .= $this->_writeAllDefinedNamesBiff8();
|
||||
$part3 .= $this->_writeMsoDrawingGroup();
|
||||
$part3 .= $this->_writeSharedStringsTable();
|
||||
}
|
||||
$part3 .= $this->_writeSupbookInternal();
|
||||
/* TODO: store external SUPBOOK records and XCT and CRN records
|
||||
in case of external references for BIFF8 */
|
||||
$part3 .= $this->_writeExternsheetBiff8();
|
||||
$part3 .= $this->_writeAllDefinedNamesBiff8();
|
||||
$part3 .= $this->_writeMsoDrawingGroup();
|
||||
$part3 .= $this->_writeSharedStringsTable();
|
||||
|
||||
$part3 .= $this->writeEof();
|
||||
|
||||
|
@ -488,11 +468,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
*/
|
||||
function _calcSheetOffsets()
|
||||
{
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record
|
||||
} else {
|
||||
$boundsheet_length = 11;
|
||||
}
|
||||
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record
|
||||
|
||||
// size of Workbook globals part 1 + 3
|
||||
$offset = $this->_datasize;
|
||||
|
@ -500,11 +476,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
// add size of Workbook globals part 2, the length of the SHEET records
|
||||
$total_worksheets = count($this->_phpExcel->getAllSheets());
|
||||
foreach ($this->_phpExcel->getWorksheetIterator() as $sheet) {
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle()));
|
||||
} else {
|
||||
$offset += $boundsheet_length + strlen($sheet->getTitle());
|
||||
}
|
||||
$offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle()));
|
||||
}
|
||||
|
||||
// add the sizes of each of the Sheet substreams, respectively
|
||||
|
@ -908,14 +880,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$grbit = 0x0000; // Visibility and sheet type
|
||||
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$data = pack("VCC", $offset, $ss, $st);
|
||||
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
|
||||
} else {
|
||||
$cch = strlen($sheetname); // Length of sheet name
|
||||
$data = pack("VCCC", $offset, $ss, $st, $cch);
|
||||
$data .= $sheetname;
|
||||
}
|
||||
$data = pack("VCC", $offset, $ss, $st);
|
||||
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname);
|
||||
|
||||
$length = strlen($data);
|
||||
$header = pack("vv", $record, $length);
|
||||
|
@ -983,23 +949,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
{
|
||||
$record = 0x041E; // Record identifier
|
||||
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$numberFormatString = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($format);
|
||||
$length = 2 + strlen($numberFormatString); // Number of bytes to follow
|
||||
} elseif ($this->_BIFF_version == 0x0500) {
|
||||
$length = 3 + strlen($format); // Number of bytes to follow
|
||||
}
|
||||
$numberFormatString = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($format);
|
||||
$length = 2 + strlen($numberFormatString); // Number of bytes to follow
|
||||
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$data = pack("v", $ifmt) . $numberFormatString;
|
||||
$this->_append($header . $data);
|
||||
} elseif ($this->_BIFF_version == 0x0500) {
|
||||
$cch = strlen($format); // Length of format string
|
||||
$data = pack("vC", $ifmt, $cch);
|
||||
$this->_append($header . $data . $format);
|
||||
}
|
||||
$data = pack("v", $ifmt) . $numberFormatString;
|
||||
$this->_append($header . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -195,7 +195,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $BIFF_version BIFF version
|
||||
* @param int $str_total Total number of strings
|
||||
* @param int $str_unique Total number of unique strings
|
||||
* @param array $str_table
|
||||
|
@ -203,19 +202,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
* @param string $tempDir The temporary directory to be used
|
||||
* @param PHPExcel_Worksheet $phpSheet
|
||||
*/
|
||||
public function __construct($BIFF_version,
|
||||
&$str_total,
|
||||
&$str_unique, &$str_table, &$colors,
|
||||
$parser, $preCalculateFormulas, $phpSheet)
|
||||
public function __construct(&$str_total, &$str_unique, &$str_table, &$colors,
|
||||
$parser, $preCalculateFormulas, $phpSheet)
|
||||
{
|
||||
// It needs to call its parent's constructor explicitly
|
||||
parent::__construct();
|
||||
|
||||
$this->_BIFF_version = $BIFF_version;
|
||||
if ($BIFF_version == 0x0600) {
|
||||
// change BIFFwriter limit for CONTINUE records
|
||||
$this->_limit = 8224;
|
||||
}
|
||||
// change BIFFwriter limit for CONTINUE records
|
||||
$this->_limit = 8224;
|
||||
|
||||
|
||||
$this->_preCalculateFormulas = $preCalculateFormulas;
|
||||
|
@ -328,9 +322,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$this->_writeGuts();
|
||||
|
||||
// Write DEFAULTROWHEIGHT
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$this->_writeDefaultRowHeight();
|
||||
}
|
||||
$this->_writeDefaultRowHeight();
|
||||
|
||||
// Write WSBOOL
|
||||
$this->_writeWsbool();
|
||||
|
@ -388,18 +380,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
}
|
||||
}
|
||||
|
||||
// Write EXTERNCOUNT of external references
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$this->_writeExterncount($num_sheets);
|
||||
}
|
||||
|
||||
// Write EXTERNSHEET references
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
for ($i = 0; $i < $num_sheets; ++$i) {
|
||||
$this->_writeExternsheet($this->_phpSheet->getParent()->getSheet($i)->getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
// Write sheet dimensions
|
||||
$this->_writeDimensions();
|
||||
|
||||
|
@ -458,9 +438,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
}
|
||||
|
||||
// Append
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$this->_writeMsoDrawing();
|
||||
}
|
||||
$this->_writeMsoDrawing();
|
||||
|
||||
$this->_writeWindow2();
|
||||
$this->_writeZoom();
|
||||
if ($this->_phpSheet->getFreezePane()) {
|
||||
|
@ -470,35 +449,31 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$this->_writeMergedCells();
|
||||
|
||||
// Hyperlinks
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
foreach ($this->_phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinate);
|
||||
foreach ($this->_phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) {
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinate);
|
||||
|
||||
$url = $hyperlink->getUrl();
|
||||
$url = $hyperlink->getUrl();
|
||||
|
||||
if ( strpos($url, 'sheet://') !== false ) {
|
||||
// internal to current workbook
|
||||
$url = str_replace('sheet://', 'internal:', $url);
|
||||
if ( strpos($url, 'sheet://') !== false ) {
|
||||
// internal to current workbook
|
||||
$url = str_replace('sheet://', 'internal:', $url);
|
||||
|
||||
} else if ( preg_match('/^(http:|https:|ftp:|mailto:)/', $url) ) {
|
||||
// URL
|
||||
// $url = $url;
|
||||
} else if ( preg_match('/^(http:|https:|ftp:|mailto:)/', $url) ) {
|
||||
// URL
|
||||
// $url = $url;
|
||||
|
||||
} else {
|
||||
// external (local file)
|
||||
$url = 'external:' . $url;
|
||||
}
|
||||
|
||||
$this->_writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
|
||||
} else {
|
||||
// external (local file)
|
||||
$url = 'external:' . $url;
|
||||
}
|
||||
|
||||
$this->_writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
|
||||
}
|
||||
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$this->_writeDataValidity();
|
||||
$this->_writeSheetLayout();
|
||||
$this->_writeSheetProtection();
|
||||
$this->_writeRangeProtection();
|
||||
}
|
||||
$this->_writeDataValidity();
|
||||
$this->_writeSheetLayout();
|
||||
$this->_writeSheetProtection();
|
||||
$this->_writeRangeProtection();
|
||||
|
||||
$this->_storeEof();
|
||||
}
|
||||
|
@ -608,10 +583,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$record = 0x0203; // Record identifier
|
||||
$length = 0x000E; // Number of bytes to follow
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvv", $row, $col, $xfIndex);
|
||||
$xl_double = pack("d", $num);
|
||||
if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvv", $row, $col, $xfIndex);
|
||||
$xl_double = pack("d", $num);
|
||||
if (self::getByteOrder()) { // if it's Big Endian
|
||||
$xl_double = strrev($xl_double);
|
||||
}
|
||||
|
||||
|
@ -629,12 +604,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
*/
|
||||
private function _writeString($row, $col, $str, $xfIndex)
|
||||
{
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$this->_writeLabelSst($row, $col, $str, $xfIndex);
|
||||
} else {
|
||||
$this->_writeLabel($row, $col, $str, $xfIndex);
|
||||
}
|
||||
$this->_writeLabelSst($row, $col, $str, $xfIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string to the specified row and column (zero indexed).
|
||||
* NOTE: there is an Excel 5 defined limit of 255 characters.
|
||||
|
@ -659,14 +631,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$str_error = 0;
|
||||
|
||||
if ($strlen > $this->_xls_strmax) { // LABEL must be < 255 chars
|
||||
$str = substr($str, 0, $this->_xls_strmax);
|
||||
$str = substr($str, 0, $this->_xls_strmax);
|
||||
$length = 0x0008 + $this->_xls_strmax;
|
||||
$strlen = $this->_xls_strmax;
|
||||
$str_error = -3;
|
||||
}
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvvv", $row, $col, $xfIndex, $strlen);
|
||||
$data = pack("vvvv", $row, $col, $xfIndex, $strlen);
|
||||
$this->_append($header . $data . $str);
|
||||
return($str_error);
|
||||
}
|
||||
|
@ -700,7 +672,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
$this->_str_total++;
|
||||
|
||||
$header = pack('vv', $record, $length);
|
||||
$data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]);
|
||||
$data = pack('vvvV', $row, $col, $xfIndex, $this->_str_table[$str]);
|
||||
$this->_append($header.$data);
|
||||
}
|
||||
|
||||
|
@ -715,14 +687,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
private function _writeNote($row, $col, $note)
|
||||
{
|
||||
$note_length = strlen($note);
|
||||
$record = 0x001C; // Record identifier
|
||||
$max_length = 2048; // Maximun length for a NOTE record
|
||||
//$length = 0x0006 + $note_length; // Bytes to follow
|
||||
$record = 0x001C; // Record identifier
|
||||
$max_length = 2048; // Maximun length for a NOTE record
|
||||
|
||||
// Length for this record is no more than 2048 + 6
|
||||
$length = 0x0006 + min($note_length, 2048);
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvv", $row, $col, $note_length);
|
||||
$data = pack("vvv", $row, $col, $note_length);
|
||||
$this->_append($header . $data . substr($note, 0, 2048));
|
||||
|
||||
for ($i = $max_length; $i < $note_length; $i += $max_length) {
|
||||
|
@ -807,46 +778,36 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
// calculated value
|
||||
if (isset($calculatedValue)) {
|
||||
|
||||
// Since we can't yet get the data type of the calculated value,
|
||||
// we use best effort to determine data type
|
||||
|
||||
if (is_bool($calculatedValue)) {
|
||||
// Boolean value
|
||||
$num = pack('CCCvCv', 0x01, 0x00, (int)$calculatedValue, 0x00, 0x00, 0xFFFF);
|
||||
|
||||
} elseif (is_int($calculatedValue) || is_float($calculatedValue)) {
|
||||
// Numeric value
|
||||
$num = pack('d', $calculatedValue);
|
||||
|
||||
} elseif (is_string($calculatedValue)) {
|
||||
if (array_key_exists($calculatedValue, PHPExcel_Cell_DataType::getErrorCodes())) {
|
||||
// Error value
|
||||
$num = pack('CCCvCv', 0x02, 0x00, $this->_mapErrorCode($calculatedValue), 0x00, 0x00, 0xFFFF);
|
||||
|
||||
} elseif ($calculatedValue === '' && $this->_BIFF_version == 0x0600) {
|
||||
} elseif ($calculatedValue === '') {
|
||||
// Empty string (and BIFF8)
|
||||
$num = pack('CCCvCv', 0x03, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
|
||||
|
||||
} else {
|
||||
// Non-empty string value (or empty string BIFF5)
|
||||
$stringValue = $calculatedValue;
|
||||
$num = pack('CCCvCv', 0x00, 0x00, 0x00, 0x00, 0x00, 0xFFFF);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
// We are really not supposed to reach here
|
||||
$num = pack('d', 0x00);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$num = pack('d', 0x00);
|
||||
}
|
||||
|
||||
$grbit = 0x03; // Option flags
|
||||
$unknown = 0x0000; // Must be zero
|
||||
$grbit = 0x03; // Option flags
|
||||
$unknown = 0x0000; // Must be zero
|
||||
|
||||
// Strip the '=' or '@' sign at the beginning of the formula string
|
||||
if ($formula{0} == '=') {
|
||||
|
@ -1218,26 +1179,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
{
|
||||
$record = 0x0200; // Record identifier
|
||||
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$length = 0x000A; // Number of bytes to follow
|
||||
$data = pack("vvvvv"
|
||||
, $this->_firstRowIndex
|
||||
, $this->_lastRowIndex + 1
|
||||
, $this->_firstColumnIndex
|
||||
, $this->_lastColumnIndex + 1
|
||||
, 0x0000 // reserved
|
||||
);
|
||||
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$length = 0x000E;
|
||||
$data = pack('VVvvv'
|
||||
, $this->_firstRowIndex
|
||||
, $this->_lastRowIndex + 1
|
||||
, $this->_firstColumnIndex
|
||||
, $this->_lastColumnIndex + 1
|
||||
, 0x0000 // reserved
|
||||
);
|
||||
}
|
||||
$length = 0x000E;
|
||||
$data = pack('VVvvv'
|
||||
, $this->_firstRowIndex
|
||||
, $this->_lastRowIndex + 1
|
||||
, $this->_firstColumnIndex
|
||||
, $this->_lastColumnIndex + 1
|
||||
, 0x0000 // reserved
|
||||
);
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$this->_append($header.$data);
|
||||
|
@ -1249,11 +1198,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
private function _writeWindow2()
|
||||
{
|
||||
$record = 0x023E; // Record identifier
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$length = 0x000A; // Number of bytes to follow
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$length = 0x0012;
|
||||
}
|
||||
$length = 0x0012;
|
||||
|
||||
$grbit = 0x00B6; // Option flags
|
||||
$rwTop = 0x0000; // Top row visible in window
|
||||
|
@ -1288,16 +1233,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvv", $grbit, $rwTop, $colLeft);
|
||||
|
||||
// FIXME !!!
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$rgbHdr = 0x00000000; // Row/column heading and gridline color
|
||||
$data .= pack("V", $rgbHdr);
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$rgbHdr = 0x0040; // Row/column heading and gridline color index
|
||||
$zoom_factor_page_break = 0x0000;
|
||||
$zoom_factor_normal = 0x0000;
|
||||
$data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
|
||||
}
|
||||
$rgbHdr = 0x0040; // Row/column heading and gridline color index
|
||||
$zoom_factor_page_break = 0x0000;
|
||||
$zoom_factor_normal = 0x0000;
|
||||
$data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
|
||||
|
||||
$this->_append($header.$data);
|
||||
}
|
||||
|
||||
|
@ -1424,13 +1366,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
// make sure we are not out of bounds
|
||||
$colFirst = min($colFirst, 255);
|
||||
$colLast = min($colLast, 255);
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$rwFirst = min($rwFirst, 65535);
|
||||
$rwLast = min($rwLast, 65535);
|
||||
} else {
|
||||
$rwFirst = min($rwFirst, 16383);
|
||||
$rwLast = min($rwLast, 16383);
|
||||
}
|
||||
|
||||
$rwFirst = min($rwFirst, 65535);
|
||||
$rwLast = min($rwLast, 65535);
|
||||
|
||||
$record = 0x001D; // Record identifier
|
||||
$length = 0x000F; // Number of bytes to follow
|
||||
|
@ -1478,11 +1416,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
}
|
||||
|
||||
// maximum allowed number of merged cells per record
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$maxCountMergeCellsPerRecord = 1027;
|
||||
} else {
|
||||
$maxCountMergeCellsPerRecord = 259;
|
||||
}
|
||||
$maxCountMergeCellsPerRecord = 1027;
|
||||
|
||||
// record identifier
|
||||
$record = 0x00E5;
|
||||
|
@ -1827,7 +1761,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$numHdr = pack("d", $numHdr);
|
||||
$numFtr = pack("d", $numFtr);
|
||||
if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
|
||||
if (self::getByteOrder()) { // if it's Big Endian
|
||||
$numHdr = strrev($numHdr);
|
||||
$numFtr = strrev($numFtr);
|
||||
}
|
||||
|
@ -1862,15 +1796,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
}
|
||||
*/
|
||||
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddHeader());
|
||||
$length = strlen($recordData);
|
||||
} else {
|
||||
$cch = strlen($this->_phpSheet->getHeaderFooter()->getOddHeader()); // Length of header string
|
||||
$length = 1 + $cch; // Bytes to follow
|
||||
$data = pack("C", $cch);
|
||||
$recordData = $data . $this->_phpSheet->getHeaderFooter()->getOddHeader();
|
||||
}
|
||||
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddHeader());
|
||||
$length = strlen($recordData);
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
|
||||
|
@ -1893,15 +1820,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
}
|
||||
*/
|
||||
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddFooter());
|
||||
$length = strlen($recordData);
|
||||
} else {
|
||||
$cch = strlen($this->_phpSheet->getHeaderFooter()->getOddFooter()); // Length of footer string
|
||||
$length = 1 + $cch;
|
||||
$data = pack("C", $cch);
|
||||
$recordData = $data . $this->_phpSheet->getHeaderFooter()->getOddFooter();
|
||||
}
|
||||
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddFooter());
|
||||
$length = strlen($recordData);
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
|
||||
|
@ -1953,7 +1873,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("d", $margin);
|
||||
if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
|
||||
if (self::getByteOrder()) { // if it's Big Endian
|
||||
$data = strrev($data);
|
||||
}
|
||||
|
||||
|
@ -1972,7 +1892,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("d", $margin);
|
||||
if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
|
||||
if (self::getByteOrder()) { // if it's Big Endian
|
||||
$data = strrev($data);
|
||||
}
|
||||
|
||||
|
@ -1991,7 +1911,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("d", $margin);
|
||||
if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
|
||||
if (self::getByteOrder()) { // if it's Big Endian
|
||||
$data = strrev($data);
|
||||
}
|
||||
|
||||
|
@ -2010,7 +1930,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("d", $margin);
|
||||
if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian
|
||||
if (self::getByteOrder()) { // if it's Big Endian
|
||||
$data = strrev($data);
|
||||
}
|
||||
|
||||
|
@ -2191,22 +2111,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$record = 0x001b; // Record identifier
|
||||
$cbrk = count($hbreaks); // Number of page breaks
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$length = 2 + 6 * $cbrk; // Bytes to follow
|
||||
} else {
|
||||
$length = 2 + 2 * $cbrk; // Bytes to follow
|
||||
}
|
||||
$length = 2 + 6 * $cbrk; // Bytes to follow
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("v", $cbrk);
|
||||
|
||||
// Append each page break
|
||||
foreach ($hbreaks as $hbreak) {
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$data .= pack("vvv", $hbreak, 0x0000, 0x00ff);
|
||||
} else {
|
||||
$data .= pack("v", $hbreak);
|
||||
}
|
||||
$data .= pack("vvv", $hbreak, 0x0000, 0x00ff);
|
||||
}
|
||||
|
||||
$this->_append($header . $data);
|
||||
|
@ -2227,22 +2139,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
|
||||
$record = 0x001a; // Record identifier
|
||||
$cbrk = count($vbreaks); // Number of page breaks
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$length = 2 + 6 * $cbrk; // Bytes to follow
|
||||
} else {
|
||||
$length = 2 + 2 * $cbrk; // Bytes to follow
|
||||
}
|
||||
$length = 2 + 6 * $cbrk; // Bytes to follow
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("v", $cbrk);
|
||||
|
||||
// Append each page break
|
||||
foreach ($vbreaks as $vbreak) {
|
||||
if ($this->_BIFF_version == 0x0600) {
|
||||
$data .= pack("vvv", $vbreak, 0x0000, 0xffff);
|
||||
} else {
|
||||
$data .= pack("v", $vbreak);
|
||||
}
|
||||
$data .= pack("vvv", $vbreak, 0x0000, 0xffff);
|
||||
}
|
||||
|
||||
$this->_append($header . $data);
|
||||
|
|
|
@ -70,13 +70,6 @@
|
|||
*/
|
||||
class PHPExcel_Writer_Excel5_Xf
|
||||
{
|
||||
/**
|
||||
* BIFF version
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_BIFFVersion;
|
||||
|
||||
/**
|
||||
* Style XF or a cell XF ?
|
||||
*
|
||||
|
@ -148,7 +141,6 @@ class PHPExcel_Writer_Excel5_Xf
|
|||
public function __construct(PHPExcel_Style $style = null)
|
||||
{
|
||||
$this->_isStyleXf = false;
|
||||
$this->_BIFFVersion = 0x0600;
|
||||
$this->_fontIndex = 0;
|
||||
|
||||
$this->_numberFormatIndex = 0;
|
||||
|
@ -218,112 +210,64 @@ class PHPExcel_Writer_Excel5_Xf
|
|||
}
|
||||
|
||||
$record = 0x00E0; // Record identifier
|
||||
if ($this->_BIFFVersion == 0x0500) {
|
||||
$length = 0x0010; // Number of bytes to follow
|
||||
}
|
||||
if ($this->_BIFFVersion == 0x0600) {
|
||||
$length = 0x0014;
|
||||
}
|
||||
$length = 0x0014; // Number of bytes to follow
|
||||
|
||||
$ifnt = $this->_fontIndex; // Index to FONT record
|
||||
$ifmt = $this->_numberFormatIndex; // Index to FORMAT record
|
||||
if ($this->_BIFFVersion == 0x0500) {
|
||||
$align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
|
||||
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
|
||||
$align |= $this->_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
|
||||
$align |= $this->_text_justlast << 7;
|
||||
$align |= 0 << 8; // rotation
|
||||
$align |= $atr_num << 10;
|
||||
$align |= $atr_fnt << 11;
|
||||
$align |= $atr_alc << 12;
|
||||
$align |= $atr_bdr << 13;
|
||||
$align |= $atr_pat << 14;
|
||||
$align |= $atr_prot << 15;
|
||||
|
||||
$icv = $this->_fg_color; // fg and bg pattern colors
|
||||
$icv |= $this->_bg_color << 7;
|
||||
$align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
|
||||
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
|
||||
$align |= $this->_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
|
||||
$align |= $this->_text_justlast << 7;
|
||||
|
||||
$fill = $this->_mapFillType($this->_style->getFill()->getFillType()); // Fill and border line style
|
||||
$fill |= $this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 6;
|
||||
$fill |= $this->_bottom_color << 9;
|
||||
$used_attrib = $atr_num << 2;
|
||||
$used_attrib |= $atr_fnt << 3;
|
||||
$used_attrib |= $atr_alc << 4;
|
||||
$used_attrib |= $atr_bdr << 5;
|
||||
$used_attrib |= $atr_pat << 6;
|
||||
$used_attrib |= $atr_prot << 7;
|
||||
|
||||
$border1 = $this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()); // Border line style and color
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) << 3;
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 6;
|
||||
$border1 |= $this->_top_color << 9;
|
||||
$icv = $this->_fg_color; // fg and bg pattern colors
|
||||
$icv |= $this->_bg_color << 7;
|
||||
|
||||
$border2 = $this->_left_color; // Border color
|
||||
$border2 |= $this->_right_color << 7;
|
||||
$border1 = $this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
|
||||
$border1 |= $this->_left_color << 16;
|
||||
$border1 |= $this->_right_color << 23;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align,
|
||||
$icv, $fill,
|
||||
$border1, $border2);
|
||||
} elseif ($this->_BIFFVersion == 0x0600) {
|
||||
$align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
|
||||
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
|
||||
$align |= $this->_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
|
||||
$align |= $this->_text_justlast << 7;
|
||||
$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
|
||||
$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
|
||||
$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
|
||||
$border1 |= $diag_tl_to_rb << 30;
|
||||
$border1 |= $diag_tr_to_lb << 31;
|
||||
|
||||
$used_attrib = $atr_num << 2;
|
||||
$used_attrib |= $atr_fnt << 3;
|
||||
$used_attrib |= $atr_alc << 4;
|
||||
$used_attrib |= $atr_bdr << 5;
|
||||
$used_attrib |= $atr_pat << 6;
|
||||
$used_attrib |= $atr_prot << 7;
|
||||
$border2 = $this->_top_color; // Border color
|
||||
$border2 |= $this->_bottom_color << 7;
|
||||
$border2 |= $this->_diag_color << 14;
|
||||
$border2 |= $this->_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
|
||||
$border2 |= $this->_mapFillType($this->_style->getFill()->getFillType()) << 26;
|
||||
|
||||
$icv = $this->_fg_color; // fg and bg pattern colors
|
||||
$icv |= $this->_bg_color << 7;
|
||||
$header = pack("vv", $record, $length);
|
||||
|
||||
$border1 = $this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
|
||||
$border1 |= $this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
|
||||
$border1 |= $this->_left_color << 16;
|
||||
$border1 |= $this->_right_color << 23;
|
||||
//BIFF8 options: identation, shrinkToFit and text direction
|
||||
$biff8_options = $this->_style->getAlignment()->getIndent();
|
||||
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
|
||||
|
||||
$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
|
||||
$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
|
||||
$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
|
||||
$border1 |= $diag_tl_to_rb << 30;
|
||||
$border1 |= $diag_tr_to_lb << 31;
|
||||
|
||||
$border2 = $this->_top_color; // Border color
|
||||
$border2 |= $this->_bottom_color << 7;
|
||||
$border2 |= $this->_diag_color << 14;
|
||||
$border2 |= $this->_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
|
||||
$border2 |= $this->_mapFillType($this->_style->getFill()->getFillType()) << 26;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
|
||||
//BIFF8 options: identation, shrinkToFit and text direction
|
||||
$biff8_options = $this->_style->getAlignment()->getIndent();
|
||||
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
|
||||
|
||||
$data = pack("vvvC", $ifnt, $ifmt, $style, $align);
|
||||
$data .= pack("CCC"
|
||||
, $this->_mapTextRotation($this->_style->getAlignment()->getTextRotation())
|
||||
, $biff8_options
|
||||
, $used_attrib
|
||||
);
|
||||
$data .= pack("VVv", $border1, $border2, $icv);
|
||||
}
|
||||
$data = pack("vvvC", $ifnt, $ifmt, $style, $align);
|
||||
$data .= pack("CCC"
|
||||
, $this->_mapTextRotation($this->_style->getAlignment()->getTextRotation())
|
||||
, $biff8_options
|
||||
, $used_attrib
|
||||
);
|
||||
$data .= pack("VVv", $border1, $border2, $icv);
|
||||
|
||||
return($header . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set BIFF version
|
||||
*
|
||||
* @param int $BIFFVersion
|
||||
*/
|
||||
public function setBIFFVersion($BIFFVersion)
|
||||
{
|
||||
$this->_BIFFVersion = $BIFFVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a style XF ?
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue