ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
Spreadsheet_Excel_Writer_BIFFwriter Class Reference
+ Inheritance diagram for Spreadsheet_Excel_Writer_BIFFwriter:
+ Collaboration diagram for Spreadsheet_Excel_Writer_BIFFwriter:

Public Member Functions

 Spreadsheet_Excel_Writer_BIFFwriter ()
 Constructor.
 _setByteOrder ()
 Determine the byte order and store it as class data to avoid recalculating it for each call to new().
 _prepend ($data)
 General storage function.
 _append ($data)
 General storage function.
 _storeBof ($type)
 Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.
 _storeEof ()
 Writes Excel EOF record to indicate the end of a BIFF stream.
 _addContinue ($data)
 Excel limits the size of BIFF records.
 Spreadsheet_Excel_Writer_BIFFwriter ()
 Constructor.
 _setByteOrder ()
 Determine the byte order and store it as class data to avoid recalculating it for each call to new().
 _prepend ($data)
 General storage function.
 _append ($data)
 General storage function.
 _storeBof ($type)
 Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.
 _storeEof ()
 Writes Excel EOF record to indicate the end of a BIFF stream.
 _addContinue ($data)
 Excel limits the size of BIFF records.
 setTempDir ($dir)
 Sets the temp dir used for storing the OLE file.
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

 $_BIFF_version = 0x0500
 $_byte_order
 $_data
 $_datasize
 $_limit
 $_tmp_dir
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Detailed Description

Definition at line 54 of file BIFFwriter.php.

Member Function Documentation

Spreadsheet_Excel_Writer_BIFFwriter::_addContinue (   $data)

Excel limits the size of BIFF records.

In Excel 5 the limit is 2084 bytes. In Excel 97 the limit is 8228 bytes. Records that are longer than these limits must be split up into CONTINUE blocks.

This function takes a long BIFF record and inserts CONTINUE records as necessary.

Parameters
string$dataThe original binary data to be written
Returns
string A very convenient string of continue blocks private

Definition at line 215 of file BIFFwriter.php.

References $_limit, and $data.

Referenced by _append(), Spreadsheet_Excel_Writer_Worksheet\_append(), and _prepend().

{
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
$header = pack("vv", $record, $limit); // Headers for continue records
// Retrieve chunks of 2080/8224 bytes +4 for the header.
for($i = $limit; $i < strlen($data) - $limit; $i += $limit)
{
$tmp .= $header;
$tmp .= substr($data, $i, $limit);
}
// Retrieve the last chunk of data
$header = pack("vv", $record, strlen($data) - $i);
$tmp .= $header;
$tmp .= substr($data,$i,strlen($data) - $i);
return $tmp;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_addContinue (   $data)

Excel limits the size of BIFF records.

In Excel 5 the limit is 2084 bytes. In Excel 97 the limit is 8228 bytes. Records that are longer than these limits must be split up into CONTINUE blocks.

This function takes a long BIFF record and inserts CONTINUE records as necessary.

Parameters
string$dataThe original binary data to be written
Returns
string A very convenient string of continue blocks private

Definition at line 219 of file BIFFwriter.php.

References $_limit, and $data.

{
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
$header = pack("vv", $record, $limit); // Headers for continue records
// Retrieve chunks of 2080/8224 bytes +4 for the header.
$data_length = strlen($data);
for ($i = $limit; $i < ($data_length - $limit); $i += $limit) {
$tmp .= $header;
$tmp .= substr($data, $i, $limit);
}
// Retrieve the last chunk of data
$header = pack("vv", $record, strlen($data) - $i);
$tmp .= $header;
$tmp .= substr($data, $i, strlen($data) - $i);
return $tmp;
}
Spreadsheet_Excel_Writer_BIFFwriter::_append (   $data)

General storage function.

Parameters
string$databinary data to append private

Reimplemented in Spreadsheet_Excel_Writer_Worksheet, and Spreadsheet_Excel_Writer_Worksheet.

Definition at line 153 of file BIFFwriter.php.

References $data, and _addContinue().

{
if (strlen($data) > $this->_limit) {
}
$this->_data = $this->_data.$data;
$this->_datasize += strlen($data);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_prepend (   $data)

General storage function.

Parameters
string$databinary data to prepend private

Definition at line 133 of file BIFFwriter.php.

References $data, and _addContinue().

Referenced by _storeBof().

{
if (strlen($data) > $this->_limit) {
}
$this->_data = $data.$this->_data;
$this->_datasize += strlen($data);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_prepend (   $data)

General storage function.

Parameters
string$databinary data to prepend private

Definition at line 138 of file BIFFwriter.php.

References $data, and _addContinue().

{
if (strlen($data) > $this->_limit) {
}
$this->_data = $data.$this->_data;
$this->_datasize += strlen($data);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_setByteOrder ( )

Determine the byte order and store it as class data to avoid recalculating it for each call to new().

private

Definition at line 108 of file BIFFwriter.php.

References PEAR\raiseError().

Referenced by Spreadsheet_Excel_Writer_BIFFwriter().

{
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$byte_order = 0; // Little Endian
}
elseif ($number == strrev($teststr)){
$byte_order = 1; // Big Endian
}
else {
// Give up. I'll fix this in a later version.
return $this->raiseError("Required floating point format ".
"not supported on this platform.");
}
$this->_byte_order = $byte_order;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_setByteOrder ( )

Determine the byte order and store it as class data to avoid recalculating it for each call to new().

private

Definition at line 115 of file BIFFwriter.php.

References PEAR\raiseError().

{
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)){
$byte_order = 1; // Big Endian
} else {
// Give up. I'll fix this in a later version.
return $this->raiseError("Required floating point format ".
"not supported on this platform.");
}
$this->_byte_order = $byte_order;
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_storeBof (   $type)

Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.

Parameters
integer$typeType of BIFF file to write: 0x0005 Workbook, 0x0010 Worksheet. private

Definition at line 165 of file BIFFwriter.php.

References $_BIFF_version, $data, and _prepend().

Referenced by Spreadsheet_Excel_Writer_Workbook\_storeWorkbook(), and Spreadsheet_Excel_Writer_Worksheet\close().

{
$record = 0x0809; // Record identifier
// 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;
$unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
$build = 0x0DBB;
$year = 0x07CC;
}
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header.$data.$unknown);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_storeBof (   $type)

Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.

Parameters
integer$typeType of BIFF file to write: 0x0005 Workbook, 0x0010 Worksheet. private

Definition at line 170 of file BIFFwriter.php.

References $_BIFF_version, $data, and _prepend().

{
$record = 0x0809; // Record identifier
// 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;
$unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
$build = 0x0DBB;
$year = 0x07CC;
}
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header . $data . $unknown);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_storeEof ( )

Writes Excel EOF record to indicate the end of a BIFF stream.

private

Definition at line 195 of file BIFFwriter.php.

References _append().

Referenced by Spreadsheet_Excel_Writer_Workbook\_storeWorkbook(), and Spreadsheet_Excel_Writer_Worksheet\close().

{
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::_storeEof ( )

Writes Excel EOF record to indicate the end of a BIFF stream.

private

Definition at line 199 of file BIFFwriter.php.

References _append().

{
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::setTempDir (   $dir)

Sets the temp dir used for storing the OLE file.

public

Parameters
string$dirThe dir to be used as temp dir
Returns
true if given dir is valid, false otherwise

Reimplemented in Spreadsheet_Excel_Writer_Workbook.

Definition at line 252 of file BIFFwriter.php.

References $dir.

{
if (is_dir($dir)) {
$this->_tmp_dir = $dir;
return true;
}
return false;
}
Spreadsheet_Excel_Writer_BIFFwriter::Spreadsheet_Excel_Writer_BIFFwriter ( )

Constructor.

public

Definition at line 92 of file BIFFwriter.php.

References _setByteOrder().

Referenced by Spreadsheet_Excel_Writer_Workbook\Spreadsheet_Excel_Writer_Workbook(), and Spreadsheet_Excel_Writer_Worksheet\Spreadsheet_Excel_Writer_Worksheet().

{
$this->_byte_order = '';
$this->_data = '';
$this->_datasize = 0;
$this->_limit = 2080;
// Set the byte order
$this->_setByteOrder();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_BIFFwriter::Spreadsheet_Excel_Writer_BIFFwriter ( )

Constructor.

public

Definition at line 98 of file BIFFwriter.php.

References _setByteOrder().

{
$this->_byte_order = '';
$this->_data = '';
$this->_datasize = 0;
$this->_limit = 2080;
$this->_tmp_dir = '';
// Set the byte order
$this->_setByteOrder();
}

+ Here is the call graph for this function:

Field Documentation

Spreadsheet_Excel_Writer_BIFFwriter::$_BIFF_version = 0x0500

Definition at line 60 of file BIFFwriter.php.

Referenced by _storeBof().

Spreadsheet_Excel_Writer_BIFFwriter::$_byte_order

Definition at line 66 of file BIFFwriter.php.

Spreadsheet_Excel_Writer_BIFFwriter::$_data

Definition at line 72 of file BIFFwriter.php.

Referenced by Spreadsheet_Excel_Writer_Worksheet\getData().

Spreadsheet_Excel_Writer_BIFFwriter::$_datasize

Definition at line 78 of file BIFFwriter.php.

Referenced by Spreadsheet_Excel_Writer_Workbook\_calcSheetOffsets().

Spreadsheet_Excel_Writer_BIFFwriter::$_limit

Definition at line 85 of file BIFFwriter.php.

Referenced by _addContinue().

Spreadsheet_Excel_Writer_BIFFwriter::$_tmp_dir

Definition at line 91 of file BIFFwriter.php.


The documentation for this class was generated from the following files: