ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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. More...
 
 _setByteOrder ()
 Determine the byte order and store it as class data to avoid recalculating it for each call to new(). More...
 
 _prepend ($data)
 General storage function. More...
 
 _append ($data)
 General storage function. More...
 
 _storeBof ($type)
 Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file. More...
 
 _storeEof ()
 Writes Excel EOF record to indicate the end of a BIFF stream. More...
 
 _addContinue ($data)
 Excel limits the size of BIFF records. More...
 
 setTempDir ($dir)
 Sets the temp dir used for storing the OLE file. More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
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. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
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. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

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

◆ _addContinue()

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 @access private

Definition at line 219 of file BIFFwriter.php.

220 {
221 $limit = $this->_limit;
222 $record = 0x003C; // Record identifier
223
224 // The first 2080/8224 bytes remain intact. However, we have to change
225 // the length field of the record.
226 $tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
227
228 $header = pack("vv", $record, $limit); // Headers for continue records
229
230 // Retrieve chunks of 2080/8224 bytes +4 for the header.
231 $data_length = strlen($data);
232 for ($i = $limit; $i < ($data_length - $limit); $i += $limit) {
233 $tmp .= $header;
234 $tmp .= substr($data, $i, $limit);
235 }
236
237 // Retrieve the last chunk of data
238 $header = pack("vv", $record, strlen($data) - $i);
239 $tmp .= $header;
240 $tmp .= substr($data, $i, strlen($data) - $i);
241
242 return $tmp;
243 }
$header
$data

References $_limit, $data, and $header.

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

+ Here is the caller graph for this function:

◆ _append()

Spreadsheet_Excel_Writer_BIFFwriter::_append (   $data)

General storage function.

Parameters
string$databinary data to append @access private

Reimplemented in Spreadsheet_Excel_Writer_Worksheet.

Definition at line 153 of file BIFFwriter.php.

154 {
155 if (strlen($data) > $this->_limit) {
156 $data = $this->_addContinue($data);
157 }
158 $this->_data = $this->_data.$data;
159 $this->_datasize += strlen($data);
160 }
_addContinue($data)
Excel limits the size of BIFF records.
Definition: BIFFwriter.php:219

References $data, and _addContinue().

Referenced by Spreadsheet_Excel_Writer_Workbook\_storeAllFonts(), Spreadsheet_Excel_Writer_Workbook\_storeAllXfs(), Spreadsheet_Excel_Writer_Workbook\_storeBoundsheet(), Spreadsheet_Excel_Writer_Workbook\_storeCodepage(), Spreadsheet_Excel_Writer_Workbook\_storeCountry(), Spreadsheet_Excel_Writer_Workbook\_storeDatemode(), _storeEof(), Spreadsheet_Excel_Writer_Workbook\_storeExterncount(), Spreadsheet_Excel_Writer_Workbook\_storeExternsheet(), Spreadsheet_Excel_Writer_Workbook\_storeExternsheetBiff8(), Spreadsheet_Excel_Writer_Workbook\_storeNameLong(), Spreadsheet_Excel_Writer_Workbook\_storeNameShort(), Spreadsheet_Excel_Writer_Workbook\_storeNumFormat(), Spreadsheet_Excel_Writer_Workbook\_storePalette(), Spreadsheet_Excel_Writer_Workbook\_storeSharedStringsTable(), Spreadsheet_Excel_Writer_Workbook\_storeStyle(), Spreadsheet_Excel_Writer_Workbook\_storeSupbookInternal(), and Spreadsheet_Excel_Writer_Workbook\_storeWindow1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _prepend()

Spreadsheet_Excel_Writer_BIFFwriter::_prepend (   $data)

General storage function.

Parameters
string$databinary data to prepend @access private

Definition at line 138 of file BIFFwriter.php.

139 {
140 if (strlen($data) > $this->_limit) {
141 $data = $this->_addContinue($data);
142 }
143 $this->_data = $data.$this->_data;
144 $this->_datasize += strlen($data);
145 }

References $data, and _addContinue().

Referenced by _storeBof().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _setByteOrder()

Spreadsheet_Excel_Writer_BIFFwriter::_setByteOrder ( )

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

@access private

Definition at line 115 of file BIFFwriter.php.

116 {
117 // Check if "pack" gives the required IEEE 64bit float
118 $teststr = pack("d", 1.2345);
119 $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
120 if ($number == $teststr) {
121 $byte_order = 0; // Little Endian
122 } elseif ($number == strrev($teststr)){
123 $byte_order = 1; // Big Endian
124 } else {
125 // Give up. I'll fix this in a later version.
126 return $this->raiseError("Required floating point format ".
127 "not supported on this platform.");
128 }
129 $this->_byte_order = $byte_order;
130 }
& 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 de...
Definition: PEAR.php:524

References PEAR\raiseError().

Referenced by Spreadsheet_Excel_Writer_BIFFwriter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _storeBof()

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. @access private

Definition at line 170 of file BIFFwriter.php.

171 {
172 $record = 0x0809; // Record identifier
173
174 // According to the SDK $build and $year should be set to zero.
175 // However, this throws a warning in Excel 5. So, use magic numbers.
176 if ($this->_BIFF_version == 0x0500) {
177 $length = 0x0008;
178 $unknown = '';
179 $build = 0x096C;
180 $year = 0x07C9;
181 } elseif ($this->_BIFF_version == 0x0600) {
182 $length = 0x0010;
183 $unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
184 $build = 0x0DBB;
185 $year = 0x07CC;
186 }
187 $version = $this->_BIFF_version;
188
189 $header = pack("vv", $record, $length);
190 $data = pack("vvvv", $version, $type, $build, $year);
191 $this->_prepend($header . $data . $unknown);
192 }
_prepend($data)
General storage function.
Definition: BIFFwriter.php:138

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _storeEof()

Spreadsheet_Excel_Writer_BIFFwriter::_storeEof ( )

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

@access private

Definition at line 199 of file BIFFwriter.php.

200 {
201 $record = 0x000A; // Record identifier
202 $length = 0x0000; // Number of bytes to follow
203 $header = pack("vv", $record, $length);
204 $this->_append($header);
205 }
_append($data)
General storage function.
Definition: BIFFwriter.php:153

References $header, and _append().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTempDir()

Spreadsheet_Excel_Writer_BIFFwriter::setTempDir (   $dir)

Sets the temp dir used for storing the OLE file.

@access public

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

Definition at line 252 of file BIFFwriter.php.

253 {
254 if (is_dir($dir)) {
255 $this->_tmp_dir = $dir;
256 return true;
257 }
258 return false;
259 }

◆ Spreadsheet_Excel_Writer_BIFFwriter()

Spreadsheet_Excel_Writer_BIFFwriter::Spreadsheet_Excel_Writer_BIFFwriter ( )

Constructor.

@access public

Definition at line 98 of file BIFFwriter.php.

99 {
100 $this->_byte_order = '';
101 $this->_data = '';
102 $this->_datasize = 0;
103 $this->_limit = 2080;
104 $this->_tmp_dir = '';
105 // Set the byte order
106 $this->_setByteOrder();
107 }
_setByteOrder()
Determine the byte order and store it as class data to avoid recalculating it for each call to new().
Definition: BIFFwriter.php:115

References _setByteOrder().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $_BIFF_version

Spreadsheet_Excel_Writer_BIFFwriter::$_BIFF_version = 0x0500

Definition at line 60 of file BIFFwriter.php.

Referenced by _storeBof().

◆ $_byte_order

Spreadsheet_Excel_Writer_BIFFwriter::$_byte_order

Definition at line 66 of file BIFFwriter.php.

◆ $_data

Spreadsheet_Excel_Writer_BIFFwriter::$_data

Definition at line 72 of file BIFFwriter.php.

Referenced by Spreadsheet_Excel_Writer_Worksheet\getData().

◆ $_datasize

Spreadsheet_Excel_Writer_BIFFwriter::$_datasize

Definition at line 78 of file BIFFwriter.php.

Referenced by Spreadsheet_Excel_Writer_Workbook\_calcSheetOffsets().

◆ $_limit

Spreadsheet_Excel_Writer_BIFFwriter::$_limit

Definition at line 85 of file BIFFwriter.php.

Referenced by _addContinue().

◆ $_tmp_dir

Spreadsheet_Excel_Writer_BIFFwriter::$_tmp_dir

Definition at line 91 of file BIFFwriter.php.


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