ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
Spreadsheet_Excel_Writer_Worksheet Class Reference
+ Inheritance diagram for Spreadsheet_Excel_Writer_Worksheet:
+ Collaboration diagram for Spreadsheet_Excel_Writer_Worksheet:

Public Member Functions

 Spreadsheet_Excel_Writer_Worksheet ($BIFF_version, $name, $index, &$activesheet, &$firstsheet, &$str_total, &$str_unique, &$str_table, &$url_format, &$parser, $tmp_dir)
 Constructor.
 _initialize ()
 Open a tmp file to store the majority of the Worksheet data.
 close ($sheetnames)
 Add data to the beginning of the workbook (note the reverse order) and to the end of the workbook.
 getName ()
 Retrieve the worksheet name.
 getData ()
 Retrieves data from memory in one chunk, or from disk in $buffer sized chunks.
 setMerge ($first_row, $first_col, $last_row, $last_col)
 Sets a merged cell range.
 select ()
 Set this worksheet as a selected worksheet, i.e.
 activate ()
 Set this worksheet as the active worksheet, i.e.
 setFirstSheet ()
 Set this worksheet as the first visible sheet.
 protect ($password)
 Set the worksheet protection flag to prevent accidental modification and to hide formulas if the locked and hidden format properties have been set.
 setColumn ($firstcol, $lastcol, $width, $format=null, $hidden=0, $level=0)
 Set the width of a single column or a range of columns.
 setSelection ($first_row, $first_column, $last_row, $last_column)
 Set which cell or cells are selected in a worksheet.
 freezePanes ($panes)
 Set panes and mark them as frozen.
 thawPanes ($panes)
 Set panes and mark them as unfrozen.
 setPortrait ()
 Set the page orientation as portrait.
 setLandscape ()
 Set the page orientation as landscape.
 setPaper ($size=0)
 Set the paper type.
 setHeader ($string, $margin=0.50)
 Set the page header caption and optional margin.
 setFooter ($string, $margin=0.50)
 Set the page footer caption and optional margin.
 centerHorizontally ($center=1)
 Center the page horinzontally.
 centerVertically ($center=1)
 Center the page vertically.
 setMargins ($margin)
 Set all the page margins to the same value in inches.
 setMargins_LR ($margin)
 Set the left and right margins to the same value in inches.
 setMargins_TB ($margin)
 Set the top and bottom margins to the same value in inches.
 setMarginLeft ($margin=0.75)
 Set the left margin in inches.
 setMarginRight ($margin=0.75)
 Set the right margin in inches.
 setMarginTop ($margin=1.00)
 Set the top margin in inches.
 setMarginBottom ($margin=1.00)
 Set the bottom margin in inches.
 repeatRows ($first_row, $last_row=null)
 Set the rows to repeat at the top of each printed page.
 repeatColumns ($first_col, $last_col=null)
 Set the columns to repeat at the left hand side of each printed page.
 printArea ($first_row, $first_col, $last_row, $last_col)
 Set the area of each worksheet that will be printed.
 hideGridlines ()
 Set the option to hide gridlines on the printed page.
 hideScreenGridlines ()
 Set the option to hide gridlines on the worksheet (as seen on the screen).
 printRowColHeaders ($print=1)
 Set the option to print the row and column headers on the printed page.
 fitToPages ($width, $height)
 Set the vertical and horizontal number of pages that will define the maximum area printed.
 setHPagebreaks ($breaks)
 Store the horizontal page breaks on a worksheet (for printing).
 setVPagebreaks ($breaks)
 Store the vertical page breaks on a worksheet (for printing).
 setZoom ($scale=100)
 Set the worksheet zoom factor.
 setPrintScale ($scale=100)
 Set the scale factor for the printed page.
 write ($row, $col, $token, $format=null)
 Map to the appropriate write method acording to the token recieved.
 writeRow ($row, $col, $val, $format=null)
 Write an array of values as a row.
 writeCol ($row, $col, $val, $format=null)
 Write an array of values as a column.
 _XF (&$format)
 Returns an index to the XF record in the workbook.
 _append ($data)
 Store Worksheet data in memory using the parent's class append() or to a temporary file, the default.
 _substituteCellref ($cell)
 Substitute an Excel cell reference in A1 notation for zero based row and column values in an argument list.
 _cellToRowcol ($cell)
 Convert an Excel cell reference in A1 notation to a zero based row and column reference; converts C1 to (0, 2).
 _encodePassword ($plaintext)
 Based on the algorithm provided by Daniel Rentz of OpenOffice.
 setOutline ($visible=true, $symbols_below=true, $symbols_right=true, $auto_style=false)
 This method sets the properties for outlining and grouping.
 writeNumber ($row, $col, $num, $format=null)
 Write a double to the specified row and column (zero indexed).
 writeString ($row, $col, $str, $format=null)
 Write a string to the specified row and column (zero indexed).
 setInputEncoding ($encoding)
 Sets Input Encoding for writing strings.
 writeStringBIFF8 ($row, $col, $str, $format=null)
 Write a string to the specified row and column (zero indexed).
 _checkRowCol ($row, $col)
 Check row and col before writing to a cell, and update the sheet's dimensions accordingly.
 writeNote ($row, $col, $note)
 Writes a note associated with the cell given by the row and column.
 writeBlank ($row, $col, $format)
 Write a blank cell to the specified row and column (zero indexed).
 writeFormula ($row, $col, $formula, $format=null)
 Write a formula to the specified row and column (zero indexed).
 writeUrl ($row, $col, $url, $string= '', $format=null)
 Write a hyperlink.
 _writeUrlRange ($row1, $col1, $row2, $col2, $url, $string= '', $format=null)
 This is the more general form of writeUrl().
 _writeUrlWeb ($row1, $col1, $row2, $col2, $url, $str, $format=null)
 Used to write http, ftp and mailto hyperlinks.
 _writeUrlInternal ($row1, $col1, $row2, $col2, $url, $str, $format=null)
 Used to write internal reference hyperlinks such as "Sheet1!A1".
 _writeUrlExternal ($row1, $col1, $row2, $col2, $url, $str, $format=null)
 Write links to external directory names such as 'c:.xls', c:.xls::Sheet1!A1', '../../foo.xls'.
 setRow ($row, $height, $format=null, $hidden=false, $level=0)
 This method is used to set the height and format for a row.
 _storeDimensions ()
 Writes Excel DIMENSIONS to define the area in which there is data.
 _storeWindow2 ()
 Write BIFF record Window2.
 _storeDefcol ()
 Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
 _storeColinfo ($col_array)
 Write BIFF record COLINFO to define column widths.
 _storeSelection ($array)
 Write BIFF record SELECTION.
 _storeMergedCells ()
 Store the MERGEDCELLS record for all ranges of merged cells.
 _storeExterncount ($count)
 Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in a worksheet.
 _storeExternsheet ($sheetname)
 Writes the Excel BIFF EXTERNSHEET record.
 _storePanes ($panes)
 Writes the Excel BIFF PANE record.
 _storeSetup ()
 Store the page setup SETUP BIFF record.
 _storeHeader ()
 Store the header caption BIFF record.
 _storeFooter ()
 Store the footer caption BIFF record.
 _storeHcenter ()
 Store the horizontal centering HCENTER BIFF record.
 _storeVcenter ()
 Store the vertical centering VCENTER BIFF record.
 _storeMarginLeft ()
 Store the LEFTMARGIN BIFF record.
 _storeMarginRight ()
 Store the RIGHTMARGIN BIFF record.
 _storeMarginTop ()
 Store the TOPMARGIN BIFF record.
 _storeMarginBottom ()
 Store the BOTTOMMARGIN BIFF record.
 mergeCells ($first_row, $first_col, $last_row, $last_col)
 Merges the area given by its arguments.
 _storePrintHeaders ()
 Write the PRINTHEADERS BIFF record.
 _storePrintGridlines ()
 Write the PRINTGRIDLINES BIFF record.
 _storeGridset ()
 Write the GRIDSET BIFF record.
 _storeGuts ()
 Write the GUTS BIFF record.
 _storeWsbool ()
 Write the WSBOOL BIFF record, mainly for fit-to-page.
 _storeHbreak ()
 Write the HORIZONTALPAGEBREAKS BIFF record.
 _storeVbreak ()
 Write the VERTICALPAGEBREAKS BIFF record.
 _storeProtect ()
 Set the Biff PROTECT record to indicate that the worksheet is protected.
 _storePassword ()
 Write the worksheet PASSWORD record.
 insertBitmap ($row, $col, $bitmap, $x=0, $y=0, $scale_x=1, $scale_y=1)
 Insert a 24bit bitmap image in a worksheet.
 _positionImage ($col_start, $row_start, $x1, $y1, $width, $height)
 Calculate the vertices that define the position of the image as required by the OBJ record.
 _sizeCol ($col)
 Convert the width of a cell from user's units to pixels.
 _sizeRow ($row)
 Convert the height of a cell from user's units to pixels.
 _storeObjPicture ($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB)
 Store the OBJ record that precedes an IMDATA record.
 _processBitmap ($bitmap)
 Convert a 24 bit bitmap into the modified internal format used by Windows.
 _storeZoom ()
 Store the window zoom factor.
 setValidation ($row1, $col1, $row2, $col2, &$validator)
 FIXME: add comments.
 _storeDataValidity ()
 Store the DVAL and DV records.
- Public Member Functions inherited from Spreadsheet_Excel_Writer_BIFFwriter
 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.
 _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

 $name
 $index
 $_url_format
 $_parser
 $_filehandle
 $_using_tmpfile
 $_xls_rowmax
 $_xls_colmax
 $_xls_strmax
 $_dim_rowmin
 $_dim_rowmax
 $_dim_colmin
 $_dim_colmax
 $_colinfo
 $_selection
 $_panes
 $_active_pane
 $_frozen
 $selected
 $_paper_size
 $_orientation
 $_header
 $_footer
 $_hcenter
 $_vcenter
 $_margin_head
 $_margin_foot
 $_margin_left
 $_margin_right
 $_margin_top
 $_margin_bottom
 $title_rowmin
 $title_rowmax
 $title_colmin
 $print_rowmin
 $print_rowmax
 $print_colmin
 $print_colmax
 $_outline_on
 $_outline_style
 $_outline_below
 $_outline_right
 $_outline_row_level
 $_fit_page
 $_fit_width
 $_fit_height
 $_str_total
 $_str_unique
 $_str_table
 $_merged_ranges
 $_input_encoding
 $record = 0x01B8
 $length = 0x00000
if(!$format) $url = preg_replace('/^external:/', '', $url)
 $url = preg_replace('/\//', "\\", $url)
if($str== '') $str_error = $this->writeString($row1, $col1, $str, $format)
if(($str_error==-2) or($str_error==-3)) $absolute = 0x02
if(!preg_match("/\\\/", $url))
if(preg_match("/^\.\.\\\/",
$url) 
$link_type ) = 0x01 | $absolute
 $dir_long = $url
if(preg_match("/\#/", $url)) $link_type = pack("V", $link_type)
 $up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless)
 $dir_short = "\0"
 $dir_short_len = pack("V", strlen($dir_short) )
 $dir_long_len = pack("V", strlen($dir_long) )
 $stream_len = pack("V", 0)
 $unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' )
 $unknown2 = pack("H*",'0303000000000000C000000000000046' )
 $unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000')
 $unknown4 = pack("v", 0x03 )
 $data
 $header = pack("vv", $record, $length)
- Data Fields inherited from Spreadsheet_Excel_Writer_BIFFwriter
 $_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 46 of file Worksheet.php.

Member Function Documentation

Spreadsheet_Excel_Writer_Worksheet::_append (   $data)

Store Worksheet data in memory using the parent's class append() or to a temporary file, the default.

private

Parameters
string$dataThe binary data to append

Reimplemented from Spreadsheet_Excel_Writer_BIFFwriter.

Definition at line 1274 of file Worksheet.php.

References $data, and Spreadsheet_Excel_Writer_BIFFwriter\_addContinue().

Referenced by _writeUrlInternal(), _writeUrlWeb(), writeBlank(), writeFormula(), writeNote(), writeNumber(), writeString(), and writeStringBIFF8().

{
if ($this->_using_tmpfile) {
// Add CONTINUE records if necessary
if (strlen($data) > $this->_limit) {
}
fwrite($this->_filehandle, $data);
$this->_datasize += strlen($data);
} else {
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_cellToRowcol (   $cell)

Convert an Excel cell reference in A1 notation to a zero based row and column reference; converts C1 to (0, 2).

private

Parameters
string$cellThe cell reference.
Returns
array containing (row, column)

Definition at line 1334 of file Worksheet.php.

References $row.

Referenced by _substituteCellref().

{
preg_match("/\$?([A-I]?[A-Z])\$?(\d+)/",$cell,$match);
$col = $match[1];
$row = $match[2];
// Convert base26 column string to number
$chars = split('', $col);
$expn = 0;
$col = 0;
while ($chars) {
$char = array_pop($chars); // LS char first
$col += (ord($char) -ord('A') +1) * pow(26,$expn);
$expn++;
}
// Convert 1-index to zero-index
$row--;
$col--;
return(array($row, $col));
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_checkRowCol (   $row,
  $col 
)

Check row and col before writing to a cell, and update the sheet's dimensions accordingly.

private

Parameters
integer$rowZero indexed row
integer$colZero indexed column
Returns
boolean true for success, false if row and/or col are grester then maximums allowed.

Definition at line 1610 of file Worksheet.php.

References $row.

Referenced by writeFormula(), and writeStringBIFF8().

{
if ($row >= $this->_xls_rowmax) {
return false;
}
if ($col >= $this->_xls_colmax) {
return false;
}
if ($row < $this->_dim_rowmin) {
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax) {
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin) {
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax) {
$this->_dim_colmax = $col;
}
return true;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_encodePassword (   $plaintext)

Based on the algorithm provided by Daniel Rentz of OpenOffice.

private

Parameters
string$plaintextThe password to be encoded in plaintext.
Returns
string The encoded password

Definition at line 1365 of file Worksheet.php.

Referenced by protect().

{
$password = 0x0000;
$i = 1; // char position
// split the plain text password in its component characters
$chars = preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $char) {
$value = ord($char) << $i; // shifted ASCII value
$rotated_bits = $value >> 15; // rotated bits beyond bit 15
$value &= 0x7fff; // first 15 bits
$password ^= ($value | $rotated_bits);
$i++;
}
$password ^= strlen($plaintext);
$password ^= 0xCE4B;
return($password);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_initialize ( )

Open a tmp file to store the majority of the Worksheet data.

If this fails, for example due to write permissions, store the data in memory. This can be slow for large files.

private

Definition at line 478 of file Worksheet.php.

Referenced by Spreadsheet_Excel_Writer_Worksheet().

{
if ($this->_using_tmpfile == false) {
return;
}
if ($this->_tmp_dir === '' && ini_get('open_basedir') === false) {
// open_basedir restriction in effect - store data in memory
// ToDo: Let the error actually have an effect somewhere
$this->_using_tmpfile = false;
return new PEAR_Error('Temp file could not be opened since open_basedir restriction in effect - please use setTmpDir() - using memory storage instead');
}
// Open tmp file for storing Worksheet data
if ($this->_tmp_dir === '') {
$fh = tmpfile();
} else {
// For people with open base dir restriction
$tmpfilename = tempnam($this->_tmp_dir, "Spreadsheet_Excel_Writer");
$fh = @fopen($tmpfilename, "w+b");
}
if ($fh === false) {
// If tmpfile() fails store data in memory
$this->_using_tmpfile = false;
} else {
// Store filehandle
$this->_filehandle = $fh;
}
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_positionImage (   $col_start,
  $row_start,
  $x1,
  $y1,
  $width,
  $height 
)

Calculate the vertices that define the position of the image as required by the OBJ record.

    +------------+------------+
    |     A      |      B     |

+--—+---------—+---------—+ | |(x1,y1) | | | 1 |(A1)._______|______ | | | | | | | | | | | +--—+-—| BITMAP |--—+ | | | | | | 2 | |______________. | | | | (B2)| | | | (x2,y2)| +-— +---------—+---------—+

Example of a bitmap that covers some of the area from cell A1 to cell B2.

Based on the width and height of the bitmap we need to calculate 8 vars: $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. The width and height of the cells are also variable and have to be taken into account. The values of $col_start and $row_start are passed in from the calling function. The values of $col_end and $row_end are calculated by subtracting the width and height of the bitmap from the width and height of the underlying cells. The vertices are expressed as a percentage of the underlying cell width as follows (rhs values are in pixels):

  x1 = X / W *1024
  y1 = Y / H *256
  x2 = (X-1) / W *1024
  y2 = (Y-1) / H *256

  Where:  X is distance from the left side of the underlying cell
          Y is distance from the top of the underlying cell
          W is the width of the cell
          H is the height of the cell

private

Note
the SDK incorrectly states that the height should be expressed as a percentage of 1024.
Parameters
integer$col_startCol containing upper left corner of object
integer$row_startRow containing top left corner of object
integer$x1Distance to left side of object
integer$y1Distance to top of object
integer$widthWidth of image frame
integer$heightHeight of image frame

Definition at line 3192 of file Worksheet.php.

{
// Initialise end cell to the same as the start cell
$col_end = $col_start; // Col containing lower right corner of object
$row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions
if ($x1 >= $this->_sizeCol($col_start)) {
$x1 = 0;
}
if ($y1 >= $this->_sizeRow($row_start)) {
$y1 = 0;
}
$width = $width + $x1 -1;
$height = $height + $y1 -1;
// Subtract the underlying cell widths to find the end cell of the image
while ($width >= $this->_sizeCol($col_end)) {
$width -= $this->_sizeCol($col_end);
$col_end++;
}
// Subtract the underlying cell heights to find the end cell of the image
while ($height >= $this->_sizeRow($row_end)) {
$height -= $this->_sizeRow($row_end);
$row_end++;
}
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
// with zero eight or width.
//
if ($this->_sizeCol($col_start) == 0) {
return;
}
if ($this->_sizeCol($col_end) == 0) {
return;
}
if ($this->_sizeRow($row_start) == 0) {
return;
}
if ($this->_sizeRow($row_end) == 0) {
return;
}
// Convert the pixel values to the percentage value expected by Excel
$x1 = $x1 / $this->_sizeCol($col_start) * 1024;
$y1 = $y1 / $this->_sizeRow($row_start) * 256;
$x2 = $width / $this->_sizeCol($col_end) * 1024; // Distance to right side of object
$y2 = $height / $this->_sizeRow($row_end) * 256; // Distance to bottom of object
$this->_storeObjPicture($col_start, $x1,
$row_start, $y1,
$col_end, $x2,
$row_end, $y2);
}
Spreadsheet_Excel_Writer_Worksheet::_processBitmap (   $bitmap)

Convert a 24 bit bitmap into the modified internal format used by Windows.

This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the MSDN library.

private

Parameters
string$bitmapThe bitmap to process
Returns
array Array with data and properties of the bitmap

Definition at line 3385 of file Worksheet.php.

References $data, and $size.

{
// Open file.
$bmp_fd = @fopen($bitmap,"rb");
if (!$bmp_fd) {
$this->raiseError("Couldn't import $bitmap");
}
// Slurp the file into a string.
$data = fread($bmp_fd, filesize($bitmap));
// Check that the file is big enough to be a bitmap.
if (strlen($data) <= 0x36) {
$this->raiseError("$bitmap doesn't contain enough data.\n");
}
// The first 2 bytes are used to identify the bitmap.
$identity = unpack("A2ident", $data);
if ($identity['ident'] != "BM") {
$this->raiseError("$bitmap doesn't appear to be a valid bitmap image.\n");
}
// Remove bitmap data: ID.
$data = substr($data, 2);
// Read and remove the bitmap size. This is more reliable than reading
// the data size at offset 0x22.
//
$size_array = unpack("Vsa", substr($data, 0, 4));
$size = $size_array['sa'];
$data = substr($data, 4);
$size -= 0x36; // Subtract size of bitmap header.
$size += 0x0C; // Add size of BIFF header.
// Remove bitmap data: reserved, offset, header length.
$data = substr($data, 12);
// Read and remove the bitmap width and height. Verify the sizes.
$width_and_height = unpack("V2", substr($data, 0, 8));
$width = $width_and_height[1];
$height = $width_and_height[2];
$data = substr($data, 8);
if ($width > 0xFFFF) {
$this->raiseError("$bitmap: largest image width supported is 65k.\n");
}
if ($height > 0xFFFF) {
$this->raiseError("$bitmap: largest image height supported is 65k.\n");
}
// Read and remove the bitmap planes and bpp data. Verify them.
$planes_and_bitcount = unpack("v2", substr($data, 0, 4));
$data = substr($data, 4);
if ($planes_and_bitcount[2] != 24) { // Bitcount
$this->raiseError("$bitmap isn't a 24bit true color bitmap.\n");
}
if ($planes_and_bitcount[1] != 1) {
$this->raiseError("$bitmap: only 1 plane supported in bitmap image.\n");
}
// Read and remove the bitmap compression. Verify compression.
$compression = unpack("Vcomp", substr($data, 0, 4));
$data = substr($data, 4);
//$compression = 0;
if ($compression['comp'] != 0) {
$this->raiseError("$bitmap: compression not supported in bitmap image.\n");
}
// Remove bitmap data: data size, hres, vres, colours, imp. colours.
$data = substr($data, 20);
// Add the BITMAPCOREHEADER data
$header = pack("Vvvvv", 0x000c, $width, $height, 0x01, 0x18);
return (array($width, $height, $size, $data));
}
Spreadsheet_Excel_Writer_Worksheet::_sizeCol (   $col)

Convert the width of a cell from user's units to pixels.

By interpolation the relationship is: y = 7x +5. If the width hasn't been set by the user we use the default value. If the col is hidden we use a value of zero.

private

Parameters
integer$colThe column
Returns
integer The width in pixels

Definition at line 3258 of file Worksheet.php.

{
// Look up the cell value to see if it has been changed
if (isset($this->col_sizes[$col])) {
if ($this->col_sizes[$col] == 0) {
return(0);
} else {
return(floor(7 * $this->col_sizes[$col] + 5));
}
} else {
return(64);
}
}
Spreadsheet_Excel_Writer_Worksheet::_sizeRow (   $row)

Convert the height of a cell from user's units to pixels.

By interpolation the relationship is: y = 4/3x. If the height hasn't been set by the user we use the default value. If the row is hidden we use a value of zero. (Not possible to hide row yet).

private

Parameters
integer$rowThe row
Returns
integer The width in pixels

Definition at line 3282 of file Worksheet.php.

References $row.

{
// Look up the cell value to see if it has been changed
if (isset($this->_row_sizes[$row])) {
if ($this->_row_sizes[$row] == 0) {
return(0);
} else {
return(floor(4/3 * $this->_row_sizes[$row]));
}
} else {
return(17);
}
}
Spreadsheet_Excel_Writer_Worksheet::_storeColinfo (   $col_array)

Write BIFF record COLINFO to define column widths.

Note: The SDK says the record length is 0x0B but Excel writes a 0x0C length record.

private

Parameters
array$col_arrayThis is the only parameter received and is composed of the following: 0 => First formatted column, 1 => Last formatted column, 2 => Col width (8.43 is Excel default), 3 => The optional XF format of the column, 4 => Option flags. 5 => Optional outline level

Definition at line 2308 of file Worksheet.php.

References $data.

Referenced by close().

{
if (isset($col_array[0])) {
$colFirst = $col_array[0];
}
if (isset($col_array[1])) {
$colLast = $col_array[1];
}
if (isset($col_array[2])) {
$coldx = $col_array[2];
} else {
$coldx = 8.43;
}
if (isset($col_array[3])) {
$format = $col_array[3];
} else {
$format = 0;
}
if (isset($col_array[4])) {
$grbit = $col_array[4];
} else {
$grbit = 0;
}
if (isset($col_array[5])) {
$level = $col_array[5];
} else {
$level = 0;
}
$record = 0x007D; // Record identifier
$length = 0x000B; // Number of bytes to follow
$coldx += 0.72; // Fudge. Excel subtracts 0.72 !?
$coldx *= 256; // Convert to units of 1/256 of a char
$ixfe = $this->_XF($format);
$reserved = 0x00; // Reserved
$level = max(0, min($level, 7));
$grbit |= $level << 8;
$header = pack("vv", $record, $length);
$data = pack("vvvvvC", $colFirst, $colLast, $coldx,
$ixfe, $grbit, $reserved);
$this->_prepend($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeDataValidity ( )

Store the DVAL and DV records.

private

Definition at line 3498 of file Worksheet.php.

References $data.

{
$record = 0x01b2; // Record identifier
$length = 0x0012; // Bytes to follow
$grbit = 0x0002; // Prompt box at cell, no cached validity data at DV records
$horPos = 0x00000000; // Horizontal position of prompt box, if fixed position
$verPos = 0x00000000; // Vertical position of prompt box, if fixed position
$objId = 0xffffffff; // Object identifier of drop down arrow object, or -1 if not visible
$header = pack('vv', $record, $length);
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId,
count($this->_dv));
$this->_append($header.$data);
$record = 0x01be; // Record identifier
foreach ($this->_dv as $dv) {
$length = strlen($dv); // Bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header . $dv);
}
}
Spreadsheet_Excel_Writer_Worksheet::_storeDefcol ( )

Write BIFF record DEFCOLWIDTH if COLINFO records are in use.

private

Definition at line 2282 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0055; // Record identifier
$length = 0x0002; // Number of bytes to follow
$colwidth = 0x0008; // Default column width
$header = pack("vv", $record, $length);
$data = pack("v", $colwidth);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeDimensions ( )

Writes Excel DIMENSIONS to define the area in which there is data.

private

Definition at line 2196 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0200; // Record identifier
$row_min = $this->_dim_rowmin; // First row
$row_max = $this->_dim_rowmax + 1; // Last row plus 1
$col_min = $this->_dim_colmin; // First column
$col_max = $this->_dim_colmax + 1; // Last column plus 1
$reserved = 0x0000; // Reserved by Excel
if ($this->_BIFF_version == 0x0500) {
$length = 0x000A; // Number of bytes to follow
$data = pack("vvvvv", $row_min, $row_max,
$col_min, $col_max, $reserved);
} elseif ($this->_BIFF_version == 0x0600) {
$length = 0x000E;
$data = pack("VVvvv", $row_min, $row_max,
$col_min, $col_max, $reserved);
}
$header = pack("vv", $record, $length);
$this->_prepend($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeExterncount (   $count)

Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in a worksheet.

Excel only stores references to external sheets that are used in formulas. For simplicity we store references to all the sheets in the workbook regardless of whether they are used or not. This reduces the overall complexity and eliminates the need for a two way dialogue between the formula parser the worksheet objects.

private

Parameters
integer$countThe number of external sheet references in this worksheet

Definition at line 2432 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow
$header = pack("vv", $record, $length);
$data = pack("v", $count);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeExternsheet (   $sheetname)

Writes the Excel BIFF EXTERNSHEET record.

These references are used by formulas. A formula references a sheet name via an index. Since we store a reference to all of the external worksheets the EXTERNSHEET index is the same as the worksheet index.

private

Parameters
string$sheetnameThe name of a external worksheet

Definition at line 2451 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0017; // Record identifier
// References to the current sheet are encoded differently to references to
// external sheets.
//
if ($this->name == $sheetname) {
$sheetname = '';
$length = 0x02; // The following 2 bytes
$cch = 1; // The following byte
$rgch = 0x02; // Self reference
} else {
$length = 0x02 + strlen($sheetname);
$cch = strlen($sheetname);
$rgch = 0x03; // Reference to a sheet in the current workbook
}
$header = pack("vv", $record, $length);
$data = pack("CC", $cch, $rgch);
$this->_prepend($header . $data . $sheetname);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeFooter ( )

Store the footer caption BIFF record.

private

Definition at line 2649 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0015; // Record identifier
$str = $this->_footer; // Footer string
$cch = strlen($str); // Length of footer string
if ($this->_BIFF_version == 0x0600) {
$encoding = 0x0; // TODO: Unicode support
$length = 3 + $cch; // Bytes to follow
} else {
$length = 1 + $cch;
}
$header = pack("vv", $record, $length);
if ($this->_BIFF_version == 0x0600) {
$data = pack("vC", $cch, $encoding);
} else {
$data = pack("C", $cch);
}
$this->_prepend($header . $data . $str);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeGridset ( )

Write the GRIDSET BIFF record.

Must be used in conjunction with the PRINTGRIDLINES record.

private

Definition at line 2865 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0082; // Record identifier
$length = 0x0002; // Bytes to follow
$fGridSet = !($this->_print_gridlines); // Boolean flag
$header = pack("vv", $record, $length);
$data = pack("v", $fGridSet);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeGuts ( )

Write the GUTS BIFF record.

This is used to configure the gutter margins where Excel outline symbols are displayed. The visibility of the gutters is controlled by a flag in WSBOOL.

See Also
_storeWsbool() private

Definition at line 2885 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0080; // Record identifier
$length = 0x0008; // Bytes to follow
$dxRwGut = 0x0000; // Size of row gutter
$dxColGut = 0x0000; // Size of col gutter
$col_level = 0;
// Calculate the maximum column outline level. The equivalent calculation
// for the row outline level is carried out in setRow().
$colcount = count($this->_colinfo);
for ($i = 0; $i < $colcount; $i++) {
// Skip cols without outline level info.
if (count($this->_colinfo[$i]) >= 6) {
$col_level = max($this->_colinfo[$i][5], $col_level);
}
}
// Set the limits for the outline levels (0 <= x <= 7).
$col_level = max(0, min($col_level, 7));
// The displayed level is one greater than the max outline levels
if ($row_level) {
$row_level++;
}
if ($col_level) {
$col_level++;
}
$header = pack("vv", $record, $length);
$data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level);
$this->_prepend($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeHbreak ( )

Write the HORIZONTALPAGEBREAKS BIFF record.

private

Definition at line 2972 of file Worksheet.php.

References $data.

Referenced by close().

{
// Return if the user hasn't specified pagebreaks
if (empty($this->_hbreaks)) {
return;
}
// Sort and filter array of page breaks
$breaks = $this->_hbreaks;
sort($breaks, SORT_NUMERIC);
if ($breaks[0] == 0) { // don't use first break if it's 0
array_shift($breaks);
}
$record = 0x001b; // Record identifier
$cbrk = count($breaks); // Number of page breaks
if ($this->_BIFF_version == 0x0600) {
$length = 2 + 6*$cbrk; // Bytes to follow
} else {
$length = 2 + 2*$cbrk; // Bytes to follow
}
$header = pack("vv", $record, $length);
$data = pack("v", $cbrk);
// Append each page break
foreach ($breaks as $break) {
if ($this->_BIFF_version == 0x0600) {
$data .= pack("vvv", $break, 0x0000, 0x00ff);
} else {
$data .= pack("v", $break);
}
}
$this->_prepend($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeHcenter ( )

Store the horizontal centering HCENTER BIFF record.

private

Definition at line 2677 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0083; // Record identifier
$length = 0x0002; // Bytes to follow
$fHCenter = $this->_hcenter; // Horizontal centering
$header = pack("vv", $record, $length);
$data = pack("v", $fHCenter);
$this->_prepend($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeHeader ( )

Store the header caption BIFF record.

private

Definition at line 2621 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0014; // Record identifier
$str = $this->_header; // header string
$cch = strlen($str); // Length of header string
if ($this->_BIFF_version == 0x0600) {
$encoding = 0x0; // TODO: Unicode support
$length = 3 + $cch; // Bytes to follow
} else {
$length = 1 + $cch; // Bytes to follow
}
$header = pack("vv", $record, $length);
if ($this->_BIFF_version == 0x0600) {
$data = pack("vC", $cch, $encoding);
} else {
$data = pack("C", $cch);
}
$this->_prepend($header.$data.$str);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeMarginBottom ( )

Store the BOTTOMMARGIN BIFF record.

private

Definition at line 2775 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0029; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_bottom; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) { // if it's Big Endian
$data = strrev($data);
}
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeMarginLeft ( )

Store the LEFTMARGIN BIFF record.

private

Definition at line 2712 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0026; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_left; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) { // if it's Big Endian
$data = strrev($data);
}
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeMarginRight ( )

Store the RIGHTMARGIN BIFF record.

private

Definition at line 2733 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0027; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_right; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) { // if it's Big Endian
$data = strrev($data);
}
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeMarginTop ( )

Store the TOPMARGIN BIFF record.

private

Definition at line 2754 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0028; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->_margin_top; // Margin in inches
$header = pack("vv", $record, $length);
$data = pack("d", $margin);
if ($this->_byte_order) { // if it's Big Endian
$data = strrev($data);
}
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeMergedCells ( )

Store the MERGEDCELLS record for all ranges of merged cells.

private

Definition at line 2402 of file Worksheet.php.

References $data.

Referenced by close().

{
// if there are no merged cell ranges set, return
if (count($this->_merged_ranges) == 0) {
return;
}
$record = 0x00E5;
$length = 2 + count($this->_merged_ranges) * 8;
$header = pack('vv', $record, $length);
$data = pack('v', count($this->_merged_ranges));
foreach ($this->_merged_ranges as $range) {
$data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]);
}
$this->_append($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeObjPicture (   $colL,
  $dxL,
  $rwT,
  $dyT,
  $colR,
  $dxR,
  $rwB,
  $dyB 
)

Store the OBJ record that precedes an IMDATA record.

This could be generalise to support other Excel objects.

private

Parameters
integer$colLColumn containing upper left corner of object
integer$dxLDistance from left side of cell
integer$rwTRow containing top left corner of object
integer$dyTDistance from top of cell
integer$colRColumn containing lower right corner of object
integer$dxRDistance from right of cell
integer$rwBRow containing bottom right corner of object
integer$dyBDistance from bottom of cell

Definition at line 3310 of file Worksheet.php.

References $data.

{
$record = 0x005d; // Record identifier
$length = 0x003c; // Bytes to follow
$cObj = 0x0001; // Count of objects in file (set to 1)
$OT = 0x0008; // Object type. 8 = Picture
$id = 0x0001; // Object ID
$grbit = 0x0614; // Option flags
$cbMacro = 0x0000; // Length of FMLA structure
$Reserved1 = 0x0000; // Reserved
$Reserved2 = 0x0000; // Reserved
$icvBack = 0x09; // Background colour
$icvFore = 0x09; // Foreground colour
$fls = 0x00; // Fill pattern
$fAuto = 0x00; // Automatic fill
$icv = 0x08; // Line colour
$lns = 0xff; // Line style
$lnw = 0x01; // Line weight
$fAutoB = 0x00; // Automatic border
$frs = 0x0000; // Frame style
$cf = 0x0009; // Image format, 9 = bitmap
$Reserved3 = 0x0000; // Reserved
$cbPictFmla = 0x0000; // Length of FMLA structure
$Reserved4 = 0x0000; // Reserved
$grbit2 = 0x0001; // Option flags
$Reserved5 = 0x0000; // Reserved
$header = pack("vv", $record, $length);
$data = pack("V", $cObj);
$data .= pack("v", $OT);
$data .= pack("v", $id);
$data .= pack("v", $grbit);
$data .= pack("v", $colL);
$data .= pack("v", $dxL);
$data .= pack("v", $rwT);
$data .= pack("v", $dyT);
$data .= pack("v", $colR);
$data .= pack("v", $dxR);
$data .= pack("v", $rwB);
$data .= pack("v", $dyB);
$data .= pack("v", $cbMacro);
$data .= pack("V", $Reserved1);
$data .= pack("v", $Reserved2);
$data .= pack("C", $icvBack);
$data .= pack("C", $icvFore);
$data .= pack("C", $fls);
$data .= pack("C", $fAuto);
$data .= pack("C", $icv);
$data .= pack("C", $lns);
$data .= pack("C", $lnw);
$data .= pack("C", $fAutoB);
$data .= pack("v", $frs);
$data .= pack("V", $cf);
$data .= pack("v", $Reserved3);
$data .= pack("v", $cbPictFmla);
$data .= pack("v", $Reserved4);
$data .= pack("v", $grbit2);
$data .= pack("V", $Reserved5);
$this->_append($header . $data);
}
Spreadsheet_Excel_Writer_Worksheet::_storePanes (   $panes)

Writes the Excel BIFF PANE record.

The panes can either be frozen or thawed (unfrozen). Frozen panes are specified in terms of an integer number of rows and columns. Thawed panes are specified in terms of Excel's units for rows and columns.

private

Parameters
array$panesThis is the only parameter received and is composed of the following: 0 => Vertical split position, 1 => Horizontal split position 2 => Top row visible 3 => Leftmost column visible 4 => Active pane

Definition at line 2488 of file Worksheet.php.

References $data.

Referenced by close().

{
$y = $panes[0];
$x = $panes[1];
$rwTop = $panes[2];
$colLeft = $panes[3];
if (count($panes) > 4) { // if Active pane was received
$pnnAct = $panes[4];
} else {
$pnnAct = null;
}
$record = 0x0041; // Record identifier
$length = 0x000A; // Number of bytes to follow
// Code specific to frozen or thawed panes.
if ($this->_frozen) {
// Set default values for $rwTop and $colLeft
if (!isset($rwTop)) {
$rwTop = $y;
}
if (!isset($colLeft)) {
$colLeft = $x;
}
} else {
// Set default values for $rwTop and $colLeft
if (!isset($rwTop)) {
$rwTop = 0;
}
if (!isset($colLeft)) {
$colLeft = 0;
}
// Convert Excel's row and column units to the internal units.
// The default row height is 12.75
// The default column width is 8.43
// The following slope and intersection values were interpolated.
//
$y = 20*$y + 255;
$x = 113.879*$x + 390;
}
// Determine which pane should be active. There is also the undocumented
// option to override this should it be necessary: may be removed later.
//
if (!isset($pnnAct)) {
if ($x != 0 && $y != 0) {
$pnnAct = 0; // Bottom right
}
if ($x != 0 && $y == 0) {
$pnnAct = 1; // Top right
}
if ($x == 0 && $y != 0) {
$pnnAct = 2; // Bottom left
}
if ($x == 0 && $y == 0) {
$pnnAct = 3; // Top left
}
}
$this->_active_pane = $pnnAct; // Used in _storeSelection
$header = pack("vv", $record, $length);
$data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
$this->_append($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storePassword ( )

Write the worksheet PASSWORD record.

private

Definition at line 3083 of file Worksheet.php.

References $data.

Referenced by close().

{
// Exit unless sheet protection and password have been specified
if (($this->_protect == 0) || (!isset($this->_password))) {
return;
}
$record = 0x0013; // Record identifier
$length = 0x0002; // Bytes to follow
$wPassword = $this->_password; // Encoded password
$header = pack("vv", $record, $length);
$data = pack("v", $wPassword);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storePrintGridlines ( )

Write the PRINTGRIDLINES BIFF record.

Must be used in conjunction with the GRIDSET record.

private

Definition at line 2847 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x002b; // Record identifier
$length = 0x0002; // Bytes to follow
$fPrintGrid = $this->_print_gridlines; // Boolean flag
$header = pack("vv", $record, $length);
$data = pack("v", $fPrintGrid);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storePrintHeaders ( )

Write the PRINTHEADERS BIFF record.

private

Definition at line 2829 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x002a; // Record identifier
$length = 0x0002; // Bytes to follow
$fPrintRwCol = $this->_print_headers; // Boolean flag
$header = pack("vv", $record, $length);
$data = pack("v", $fPrintRwCol);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeProtect ( )

Set the Biff PROTECT record to indicate that the worksheet is protected.

private

Definition at line 3060 of file Worksheet.php.

References $data.

Referenced by close().

{
// Exit unless sheet protection has been specified
if ($this->_protect == 0) {
return;
}
$record = 0x0012; // Record identifier
$length = 0x0002; // Bytes to follow
$fLock = $this->_protect; // Worksheet is protected
$header = pack("vv", $record, $length);
$data = pack("v", $fLock);
$this->_prepend($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeSelection (   $array)

Write BIFF record SELECTION.

private

Parameters
array$arrayarray containing ($rwFirst,$colFirst,$rwLast,$colLast)
See Also
setSelection()

Definition at line 2361 of file Worksheet.php.

References $data.

Referenced by close().

{
list($rwFirst,$colFirst,$rwLast,$colLast) = $array;
$record = 0x001D; // Record identifier
$length = 0x000F; // Number of bytes to follow
$pnn = $this->_active_pane; // Pane position
$rwAct = $rwFirst; // Active row
$colAct = $colFirst; // Active column
$irefAct = 0; // Active cell ref
$cref = 1; // Number of refs
if (!isset($rwLast)) {
$rwLast = $rwFirst; // Last row in reference
}
if (!isset($colLast)) {
$colLast = $colFirst; // Last col in reference
}
// Swap last row/col for first row/col as necessary
if ($rwFirst > $rwLast) {
list($rwFirst, $rwLast) = array($rwLast, $rwFirst);
}
if ($colFirst > $colLast) {
list($colFirst, $colLast) = array($colLast, $colFirst);
}
$header = pack("vv", $record, $length);
$data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct,
$irefAct, $cref,
$rwFirst, $rwLast,
$colFirst, $colLast);
$this->_append($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeSetup ( )

Store the page setup SETUP BIFF record.

private

Definition at line 2560 of file Worksheet.php.

Referenced by close().

{
$record = 0x00A1; // Record identifier
$length = 0x0022; // Number of bytes to follow
$iPaperSize = $this->_paper_size; // Paper size
$iScale = $this->_print_scale; // Print scaling factor
$iPageStart = 0x01; // Starting page number
$iFitWidth = $this->_fit_width; // Fit to number of pages wide
$iFitHeight = $this->_fit_height; // Fit to number of pages high
$grbit = 0x00; // Option flags
$iRes = 0x0258; // Print resolution
$iVRes = 0x0258; // Vertical print resolution
$numHdr = $this->_margin_head; // Header Margin
$numFtr = $this->_margin_foot; // Footer Margin
$iCopies = 0x01; // Number of copies
$fLeftToRight = 0x0; // Print over then down
$fLandscape = $this->_orientation; // Page orientation
$fNoPls = 0x0; // Setup not read from printer
$fNoColor = 0x0; // Print black and white
$fDraft = 0x0; // Print draft quality
$fNotes = 0x0; // Print notes
$fNoOrient = 0x0; // Orientation not set
$fUsePage = 0x0; // Use custom starting page
$grbit = $fLeftToRight;
$grbit |= $fLandscape << 1;
$grbit |= $fNoPls << 2;
$grbit |= $fNoColor << 3;
$grbit |= $fDraft << 4;
$grbit |= $fNotes << 5;
$grbit |= $fNoOrient << 6;
$grbit |= $fUsePage << 7;
$numHdr = pack("d", $numHdr);
$numFtr = pack("d", $numFtr);
if ($this->_byte_order) { // if it's Big Endian
$numHdr = strrev($numHdr);
$numFtr = strrev($numFtr);
}
$header = pack("vv", $record, $length);
$data1 = pack("vvvvvvvv", $iPaperSize,
$iScale,
$iPageStart,
$iFitWidth,
$iFitHeight,
$grbit,
$iRes,
$iVRes);
$data2 = $numHdr.$numFtr;
$data3 = pack("v", $iCopies);
$this->_prepend($header . $data1 . $data2 . $data3);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeVbreak ( )

Write the VERTICALPAGEBREAKS BIFF record.

private

Definition at line 3015 of file Worksheet.php.

References $data.

Referenced by close().

{
// Return if the user hasn't specified pagebreaks
if (empty($this->_vbreaks)) {
return;
}
// 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
// It is slightly higher in Excel 97/200, approx. 1026
$breaks = array_slice($this->_vbreaks,0,1000);
// Sort and filter array of page breaks
sort($breaks, SORT_NUMERIC);
if ($breaks[0] == 0) { // don't use first break if it's 0
array_shift($breaks);
}
$record = 0x001a; // Record identifier
$cbrk = count($breaks); // Number of page breaks
if ($this->_BIFF_version == 0x0600) {
$length = 2 + 6*$cbrk; // Bytes to follow
} else {
$length = 2 + 2*$cbrk; // Bytes to follow
}
$header = pack("vv", $record, $length);
$data = pack("v", $cbrk);
// Append each page break
foreach ($breaks as $break) {
if ($this->_BIFF_version == 0x0600) {
$data .= pack("vvv", $break, 0x0000, 0xffff);
} else {
$data .= pack("v", $break);
}
}
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeVcenter ( )

Store the vertical centering VCENTER BIFF record.

private

Definition at line 2695 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0084; // Record identifier
$length = 0x0002; // Bytes to follow
$fVCenter = $this->_vcenter; // Horizontal centering
$header = pack("vv", $record, $length);
$data = pack("v", $fVCenter);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeWindow2 ( )

Write BIFF record Window2.

private

Definition at line 2223 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x023E; // Record identifier
if ($this->_BIFF_version == 0x0500) {
$length = 0x000A; // Number of bytes to follow
} elseif ($this->_BIFF_version == 0x0600) {
$length = 0x0012;
}
$grbit = 0x00B6; // Option flags
$rwTop = 0x0000; // Top row visible in window
$colLeft = 0x0000; // Leftmost column visible in window
// The options flags that comprise $grbit
$fDspFmla = 0; // 0 - bit
$fDspGrid = $this->_screen_gridlines; // 1
$fDspRwCol = 1; // 2
$fFrozen = $this->_frozen; // 3
$fDspZeros = 1; // 4
$fDefaultHdr = 1; // 5
$fArabic = 0; // 6
$fDspGuts = $this->_outline_on; // 7
$fFrozenNoSplit = 0; // 0 - bit
$fSelected = $this->selected; // 1
$fPaged = 1; // 2
$grbit = $fDspFmla;
$grbit |= $fDspGrid << 1;
$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;
$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);
}
$this->_append($header.$data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeWsbool ( )

Write the WSBOOL BIFF record, mainly for fit-to-page.

Used in conjunction with the SETUP record.

private

Definition at line 2930 of file Worksheet.php.

References $data.

Referenced by close().

{
$record = 0x0081; // Record identifier
$length = 0x0002; // Bytes to follow
$grbit = 0x0000;
// The only option that is of interest is the flag for fit to page. So we
// set all the options in one go.
//
/*if ($this->_fit_page) {
$grbit = 0x05c1;
} else {
$grbit = 0x04c1;
}*/
// Set the option flags
$grbit |= 0x0001; // Auto page breaks visible
if ($this->_outline_style) {
$grbit |= 0x0020; // Auto outline styles
}
if ($this->_outline_below) {
$grbit |= 0x0040; // Outline summary below
}
if ($this->_outline_right) {
$grbit |= 0x0080; // Outline summary right
}
if ($this->_fit_page) {
$grbit |= 0x0100; // Page setup fit to page
}
if ($this->_outline_on) {
$grbit |= 0x0400; // Outline symbols displayed
}
$header = pack("vv", $record, $length);
$data = pack("v", $grbit);
$this->_prepend($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_storeZoom ( )

Store the window zoom factor.

This should be a reduced fraction but for simplicity we will store all fractions with a numerator of 100.

private

Definition at line 3469 of file Worksheet.php.

References $data.

Referenced by close().

{
// If scale is 100 we don't need to write a record
if ($this->_zoom == 100) {
return;
}
$record = 0x00A0; // Record identifier
$length = 0x0004; // Bytes to follow
$header = pack("vv", $record, $length);
$data = pack("vv", $this->_zoom, 100);
$this->_append($header . $data);
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_substituteCellref (   $cell)

Substitute an Excel cell reference in A1 notation for zero based row and column values in an argument list.

Ex: ("A4", "Hello") is converted to (3, 0, "Hello").

private

Parameters
string$cellThe cell reference. Or range of cells.
Returns
array

Definition at line 1298 of file Worksheet.php.

References _cellToRowcol(), PEAR_ERROR_DIE, and PEAR\raiseError().

{
$cell = strtoupper($cell);
// Convert a column range: 'A:A' or 'B:G'
if (preg_match("/([A-I]?[A-Z]):([A-I]?[A-Z])/", $cell, $match)) {
list($no_use, $col1) = $this->_cellToRowcol($match[1] .'1'); // Add a dummy row
list($no_use, $col2) = $this->_cellToRowcol($match[2] .'1'); // Add a dummy row
return(array($col1, $col2));
}
// Convert a cell range: 'A1:B7'
if (preg_match("/\$?([A-I]?[A-Z]\$?\d+):\$?([A-I]?[A-Z]\$?\d+)/", $cell, $match)) {
list($row1, $col1) = $this->_cellToRowcol($match[1]);
list($row2, $col2) = $this->_cellToRowcol($match[2]);
return(array($row1, $col1, $row2, $col2));
}
// Convert a cell reference: 'A1' or 'AD2000'
if (preg_match("/\$?([A-I]?[A-Z]\$?\d+)/", $cell)) {
list($row1, $col1) = $this->_cellToRowcol($match[1]);
return(array($row1, $col1));
}
// TODO use real error codes
$this->raiseError("Unknown cell reference $cell", 0, PEAR_ERROR_DIE);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_writeUrlExternal (   $row1,
  $col1,
  $row2,
  $col2,
  $url,
  $str,
  $format = null 
)

Write links to external directory names such as 'c:.xls', c:.xls::Sheet1!A1', '../../foo.xls'.

and '../../foo.xls::Sheet1!A1'.

Note: Excel writes some relative links with the $dir_long string. We ignore these cases for the sake of simpler code.

private

See Also
writeUrl()
Parameters
integer$row1Start row
integer$col1Start column
integer$row2End row
integer$col2End column
string$urlURL string
string$strAlternative label
mixed$formatThe cell format
Returns
integer

Definition at line 2013 of file Worksheet.php.

Referenced by _writeUrlRange().

{
// Network drives are different. We will handle them separately
// MS/Novell network drives and shares start with \\
if (preg_match('[^external:\\\\]', $url)) {
return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
}
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if (!$format) {
$format = $this->_url_format;
}
// Strip URL type and change Unix dir separator to Dos style (if needed)
//
$url = preg_replace('/^external:/', '', $url);
$url = preg_replace('/\//', "\\", $url);
// Write the visible label
if ($str == '') {
$str = preg_replace('/\#/', ' - ', $url);
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) or ($str_error == -3)) {
return $str_error;
}
// Determine if the link is relative or absolute:
// relative if link contains no dir separator, "somefile.xls"
// relative if link starts with up-dir, "..\..\somefile.xls"
// otherwise, absolute
$absolute = 0x02; // Bit mask
if (!preg_match("/\\\/", $url)) {
$absolute = 0x00;
}
if (preg_match("/^\.\.\\\/", $url)) {
$absolute = 0x00;
}
// Determine if the link contains a sheet reference and change some of the
// parameters accordingly.
// Split the dir name and sheet name (if it exists)
/*if (preg_match("/\#/", $url)) {
list($dir_long, $sheet) = split("\#", $url);
} else {
$dir_long = $url;
}
if (isset($sheet)) {
$link_type |= 0x08;
$sheet_len = pack("V", strlen($sheet) + 0x01);
$sheet = join("\0", split('', $sheet));
$sheet .= "\0\0\0";
} else {
$sheet_len = '';
$sheet = '';
}*/
if (preg_match("/\#/", $url)) {
$link_type |= 0x08;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_writeUrlInternal (   $row1,
  $col1,
  $row2,
  $col2,
  $url,
  $str,
  $format = null 
)

Used to write internal reference hyperlinks such as "Sheet1!A1".

private

See Also
writeUrl()
Parameters
integer$row1Start row
integer$col1Start column
integer$row2End row
integer$col2End column
string$urlURL string
string$strAlternative label
mixed$formatThe cell format
Returns
integer

Definition at line 1947 of file Worksheet.php.

References $_url_format, $data, $header, $length, $record, $str_error, $unknown1, $url, _append(), and writeString().

Referenced by _writeUrlRange().

{
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if (!$format) {
$format = $this->_url_format;
}
// Strip URL type
$url = preg_replace('/^internal:/', '', $url);
// Write the visible label
if ($str == '') {
$str = $url;
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) || ($str_error == -3)) {
return $str_error;
}
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
// Pack the option flags
$options = pack("V", 0x08);
// Convert the URL type and to a null terminated wchar string
$url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
$url = $url . "\0\0\0";
// Pack the length of the URL as chars (not wchars)
$url_len = pack("V", floor(strlen($url)/2));
// Calculate the data length
$length = 0x24 + strlen($url);
// Pack the header data
$header = pack("vv", $record, $length);
$data = pack("vvvv", $row1, $row2, $col1, $col2);
// Write the packed data
$this->_append($header . $data .
$unknown1 . $options .
$url_len . $url);
return($str_error);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_writeUrlRange (   $row1,
  $col1,
  $row2,
  $col2,
  $url,
  $string = '',
  $format = null 
)

This is the more general form of writeUrl().

It allows a hyperlink to be written to a range of cells. This function also decides the type of hyperlink to be written. These are either, Web (http, ftp, mailto), Internal (Sheet1!A1) or external ('c:.xls::Sheet1!A1').

private

See Also
writeUrl()
Parameters
integer$row1Start row
integer$col1Start column
integer$row2End row
integer$col2End column
string$urlURL string
string$stringAlternative label
mixed$formatThe cell format
Returns
integer

Definition at line 1857 of file Worksheet.php.

References $url, _writeUrlExternal(), _writeUrlInternal(), and _writeUrlWeb().

Referenced by writeUrl().

{
// Check for internal/external sheet links or default to web link
if (preg_match('[^internal:]', $url)) {
return($this->_writeUrlInternal($row1, $col1, $row2, $col2, $url, $string, $format));
}
if (preg_match('[^external:]', $url)) {
return($this->_writeUrlExternal($row1, $col1, $row2, $col2, $url, $string, $format));
}
return($this->_writeUrlWeb($row1, $col1, $row2, $col2, $url, $string, $format));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_writeUrlWeb (   $row1,
  $col1,
  $row2,
  $col2,
  $url,
  $str,
  $format = null 
)

Used to write http, ftp and mailto hyperlinks.

The link type ($options) is 0x03 is the same as absolute dir ref without sheet. However it is differentiated by the $unknown2 data stream.

private

See Also
writeUrl()
Parameters
integer$row1Start row
integer$col1Start column
integer$row2End row
integer$col2End column
string$urlURL string
string$strAlternative label
mixed$formatThe cell format
Returns
integer

Definition at line 1887 of file Worksheet.php.

References $_url_format, $data, $header, $length, $record, $str_error, $unknown1, $unknown2, $url, _append(), and writeString().

Referenced by _writeUrlRange().

{
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
if (!$format) {
$format = $this->_url_format;
}
// Write the visible label using the writeString() method.
if ($str == '') {
$str = $url;
}
$str_error = $this->writeString($row1, $col1, $str, $format);
if (($str_error == -2) || ($str_error == -3)) {
return $str_error;
}
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000");
$unknown2 = pack("H*", "E0C9EA79F9BACE118C8200AA004BA90B");
// Pack the option flags
$options = pack("V", 0x03);
// Convert URL to a null terminated wchar string
$url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY));
$url = $url . "\0\0\0";
// Pack the length of the URL
$url_len = pack("V", strlen($url));
// Calculate the data length
$length = 0x34 + strlen($url);
// Pack the header data
$header = pack("vv", $record, $length);
$data = pack("vvvv", $row1, $row2, $col1, $col2);
// Write the packed data
$this->_append($header . $data .
$unknown1 . $options .
$unknown2 . $url_len . $url);
return($str_error);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::_XF ( $format)

Returns an index to the XF record in the workbook.

private

Parameters
mixed&$formatThe optional XF format
Returns
integer The XF record index

Definition at line 1250 of file Worksheet.php.

Referenced by writeBlank(), writeFormula(), writeNumber(), writeString(), and writeStringBIFF8().

{
if ($format) {
return($format->getXfIndex());
} else {
return(0x0F);
}
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::activate ( )

Set this worksheet as the active worksheet, i.e.

the worksheet that is displayed when the workbook is opened. Also set it as selected.

public

Definition at line 710 of file Worksheet.php.

References $index.

{
$this->selected = 1;
$this->activesheet = $this->index;
}
Spreadsheet_Excel_Writer_Worksheet::centerHorizontally (   $center = 1)

Center the page horinzontally.

public

Parameters
integer$centerthe optional value for centering. Defaults to 1 (center).

Definition at line 885 of file Worksheet.php.

{
$this->_hcenter = $center;
}
Spreadsheet_Excel_Writer_Worksheet::centerVertically (   $center = 1)

Center the page vertically.

public

Parameters
integer$centerthe optional value for centering. Defaults to 1 (center).

Definition at line 896 of file Worksheet.php.

{
$this->_vcenter = $center;
}
Spreadsheet_Excel_Writer_Worksheet::close (   $sheetnames)

Add data to the beginning of the workbook (note the reverse order) and to the end of the workbook.

public

See Also
Spreadsheet_Excel_Writer_Workbook::storeWorkbook()
Parameters
array$sheetnamesThe array of sheetnames from the Workbook this worksheet belongs to

Definition at line 518 of file Worksheet.php.

References Spreadsheet_Excel_Writer_BIFFwriter\_storeBof(), _storeColinfo(), _storeDefcol(), _storeDimensions(), Spreadsheet_Excel_Writer_BIFFwriter\_storeEof(), _storeExterncount(), _storeExternsheet(), _storeFooter(), _storeGridset(), _storeGuts(), _storeHbreak(), _storeHcenter(), _storeHeader(), _storeMarginBottom(), _storeMarginLeft(), _storeMarginRight(), _storeMarginTop(), _storeMergedCells(), _storePanes(), _storePassword(), _storePrintGridlines(), _storePrintHeaders(), _storeProtect(), _storeSelection(), _storeSetup(), _storeVbreak(), _storeVcenter(), _storeWindow2(), _storeWsbool(), and _storeZoom().

{
$num_sheets = count($sheetnames);
/***********************************************
* Prepend in reverse order!!
*/
// Prepend the sheet dimensions
$this->_storeDimensions();
// Prepend the sheet password
$this->_storePassword();
// Prepend the sheet protection
$this->_storeProtect();
// Prepend the page setup
$this->_storeSetup();
/* FIXME: margins are actually appended */
// Prepend the bottom margin
// Prepend the top margin
$this->_storeMarginTop();
// Prepend the right margin
// Prepend the left margin
$this->_storeMarginLeft();
// Prepend the page vertical centering
$this->_storeVcenter();
// Prepend the page horizontal centering
$this->_storeHcenter();
// Prepend the page footer
$this->_storeFooter();
// Prepend the page header
$this->_storeHeader();
// Prepend the vertical page breaks
$this->_storeVbreak();
// Prepend the horizontal page breaks
$this->_storeHbreak();
// Prepend WSBOOL
$this->_storeWsbool();
// Prepend GRIDSET
$this->_storeGridset();
// Prepend GUTS
if ($this->_BIFF_version == 0x0500) {
$this->_storeGuts();
}
// Prepend PRINTGRIDLINES
// Prepend PRINTHEADERS
// Prepend EXTERNSHEET references
if ($this->_BIFF_version == 0x0500) {
for ($i = $num_sheets; $i > 0; $i--) {
$sheetname = $sheetnames[$i-1];
$this->_storeExternsheet($sheetname);
}
}
// Prepend the EXTERNCOUNT of external references.
if ($this->_BIFF_version == 0x0500) {
$this->_storeExterncount($num_sheets);
}
// Prepend the COLINFO records if they exist
if (!empty($this->_colinfo)) {
$colcount = count($this->_colinfo);
for ($i = 0; $i < $colcount; $i++) {
$this->_storeColinfo($this->_colinfo[$i]);
}
$this->_storeDefcol();
}
// Prepend the BOF record
$this->_storeBof(0x0010);
/*
* End of prepend. Read upwards from here.
***********************************************/
// Append
$this->_storeWindow2();
$this->_storeZoom();
if (!empty($this->_panes)) {
$this->_storePanes($this->_panes);
}
$this->_storeSelection($this->_selection);
/* TODO: add data validity */
/*if ($this->_BIFF_version == 0x0600) {
$this->_storeDataValidity();
}*/
$this->_storeEof();
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::fitToPages (   $width,
  $height 
)

Set the vertical and horizontal number of pages that will define the maximum area printed.

It doesn't seem to work with OpenOffice.

public

Parameters
integer$widthMaximun width of printed area in pages
integer$heightMaximun heigth of printed area in pages
See Also
setPrintScale()

Definition at line 1075 of file Worksheet.php.

{
$this->_fit_page = 1;
$this->_fit_width = $width;
$this->_fit_height = $height;
}
Spreadsheet_Excel_Writer_Worksheet::freezePanes (   $panes)

Set panes and mark them as frozen.

public

Parameters
array$panesThis is the only parameter received and is composed of the following: 0 => Vertical split position, 1 => Horizontal split position 2 => Top row visible 3 => Leftmost column visible 4 => Active pane

Definition at line 790 of file Worksheet.php.

{
$this->_frozen = 1;
$this->_panes = $panes;
}
Spreadsheet_Excel_Writer_Worksheet::getData ( )

Retrieves data from memory in one chunk, or from disk in $buffer sized chunks.

Returns
string The data

Definition at line 648 of file Worksheet.php.

References Spreadsheet_Excel_Writer_BIFFwriter\$_data, and $_filehandle.

{
$buffer = 4096;
// Return data stored in memory
if (isset($this->_data)) {
$tmp = $this->_data;
unset($this->_data);
if ($this->_using_tmpfile) {
fseek($fh, 0);
}
return $tmp;
}
// Return data stored on disk
if ($this->_using_tmpfile) {
if ($tmp = fread($this->_filehandle, $buffer)) {
return $tmp;
}
}
// No data to return
return '';
}
Spreadsheet_Excel_Writer_Worksheet::getName ( )

Retrieve the worksheet name.

This is usefull when creating worksheets without a name.

public

Returns
string The worksheet's name

Definition at line 637 of file Worksheet.php.

References $name.

{
return $this->name;
}
Spreadsheet_Excel_Writer_Worksheet::hideGridlines ( )

Set the option to hide gridlines on the printed page.

public

Definition at line 1040 of file Worksheet.php.

{
$this->_print_gridlines = 0;
}
Spreadsheet_Excel_Writer_Worksheet::hideScreenGridlines ( )

Set the option to hide gridlines on the worksheet (as seen on the screen).

public

Definition at line 1050 of file Worksheet.php.

{
$this->_screen_gridlines = 0;
}
Spreadsheet_Excel_Writer_Worksheet::insertBitmap (   $row,
  $col,
  $bitmap,
  $x = 0,
  $y = 0,
  $scale_x = 1,
  $scale_y = 1 
)

Insert a 24bit bitmap image in a worksheet.

public

Parameters
integer$rowThe row we are going to insert the bitmap into
integer$colThe column we are going to insert the bitmap into
string$bitmapThe bitmap filename
integer$xThe horizontal position (offset) of the image inside the cell.
integer$yThe vertical position (offset) of the image inside the cell.
integer$scale_xThe horizontal scale
integer$scale_yThe vertical scale

Definition at line 3114 of file Worksheet.php.

References $data, $row, and $size.

{
$bitmap_array = $this->_processBitmap($bitmap);
if ($this->isError($bitmap_array)) {
$this->writeString($row, $col, $bitmap_array->getMessage());
return;
}
list($width, $height, $size, $data) = $bitmap_array; //$this->_processBitmap($bitmap);
// Scale the frame of the image.
$width *= $scale_x;
$height *= $scale_y;
// Calculate the vertices of the image and write the OBJ record
$this->_positionImage($col, $row, $x, $y, $width, $height);
// Write the IMDATA record to store the bitmap data
$record = 0x007f;
$length = 8 + $size;
$cf = 0x09;
$env = 0x01;
$lcb = $size;
$header = pack("vvvvV", $record, $length, $cf, $env, $lcb);
$this->_append($header.$data);
}
Spreadsheet_Excel_Writer_Worksheet::mergeCells (   $first_row,
  $first_col,
  $last_row,
  $last_col 
)

Merges the area given by its arguments.

This is an Excel97/2000 method. It is required to perform more complicated merging than the normal setAlign('merge').

public

Parameters
integer$first_rowFirst row of the area to merge
integer$first_colFirst column of the area to merge
integer$last_rowLast row of the area to merge
integer$last_colLast column of the area to merge

Definition at line 2802 of file Worksheet.php.

References $data.

{
$record = 0x00E5; // Record identifier
$length = 0x000A; // Bytes to follow
$cref = 1; // Number of refs
// Swap last row/col for first row/col as necessary
if ($first_row > $last_row) {
list($first_row, $last_row) = array($last_row, $first_row);
}
if ($first_col > $last_col) {
list($first_col, $last_col) = array($last_col, $first_col);
}
$header = pack("vv", $record, $length);
$data = pack("vvvvv", $cref, $first_row, $last_row,
$first_col, $last_col);
$this->_append($header.$data);
}
Spreadsheet_Excel_Writer_Worksheet::printArea (   $first_row,
  $first_col,
  $last_row,
  $last_col 
)

Set the area of each worksheet that will be printed.

public

Parameters
integer$first_rowFirst row of the area to print
integer$first_colFirst column of the area to print
integer$last_rowLast row of the area to print
integer$last_colLast column of the area to print

Definition at line 1026 of file Worksheet.php.

{
$this->print_rowmin = $first_row;
$this->print_colmin = $first_col;
$this->print_rowmax = $last_row;
$this->print_colmax = $last_col;
}
Spreadsheet_Excel_Writer_Worksheet::printRowColHeaders (   $print = 1)

Set the option to print the row and column headers on the printed page.

public

Parameters
integer$printWhether to print the headers or not. Defaults to 1 (print).

Definition at line 1061 of file Worksheet.php.

{
$this->_print_headers = $print;
}
Spreadsheet_Excel_Writer_Worksheet::protect (   $password)

Set the worksheet protection flag to prevent accidental modification and to hide formulas if the locked and hidden format properties have been set.

public

Parameters
string$passwordThe password to use for protecting the sheet.

Definition at line 736 of file Worksheet.php.

References _encodePassword().

{
$this->_protect = 1;
$this->_password = $this->_encodePassword($password);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::repeatColumns (   $first_col,
  $last_col = null 
)

Set the columns to repeat at the left hand side of each printed page.

public

Parameters
integer$first_colFirst column to repeat
integer$last_colLast column to repeat. Optional.

Definition at line 1007 of file Worksheet.php.

{
$this->title_colmin = $first_col;
if (isset($last_col)) { // Second col is optional
$this->title_colmax = $last_col;
} else {
$this->title_colmax = $first_col;
}
}
Spreadsheet_Excel_Writer_Worksheet::repeatRows (   $first_row,
  $last_row = null 
)

Set the rows to repeat at the top of each printed page.

public

Parameters
integer$first_rowFirst row to repeat
integer$last_rowLast row to repeat. Optional.

Definition at line 990 of file Worksheet.php.

{
$this->title_rowmin = $first_row;
if (isset($last_row)) { //Second row is optional
$this->title_rowmax = $last_row;
} else {
$this->title_rowmax = $first_row;
}
}
Spreadsheet_Excel_Writer_Worksheet::select ( )

Set this worksheet as a selected worksheet, i.e.

the worksheet has its tab highlighted.

public

Definition at line 698 of file Worksheet.php.

{
$this->selected = 1;
}
Spreadsheet_Excel_Writer_Worksheet::setColumn (   $firstcol,
  $lastcol,
  $width,
  $format = null,
  $hidden = 0,
  $level = 0 
)

Set the width of a single column or a range of columns.

public

Parameters
integer$firstcolfirst column on the range
integer$lastcollast column on the range
integer$widthwidth to set
mixed$formatThe optional XF format to apply to the columns
integer$hiddenThe optional hidden atribute
integer$levelThe optional outline level

Definition at line 753 of file Worksheet.php.

{
$this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level);
// Set width to zero if column is hidden
$width = ($hidden) ? 0 : $width;
for ($col = $firstcol; $col <= $lastcol; $col++) {
$this->col_sizes[$col] = $width;
}
}
Spreadsheet_Excel_Writer_Worksheet::setFirstSheet ( )

Set this worksheet as the first visible sheet.

This is necessary when there are a large number of worksheets and the activated worksheet is not visible on the screen.

public

Definition at line 723 of file Worksheet.php.

References $index.

{
$this->firstsheet = $this->index;
}
Spreadsheet_Excel_Writer_Worksheet::setFooter (   $string,
  $margin = 0.50 
)

Set the page footer caption and optional margin.

public

Parameters
string$stringThe footer text
float$marginoptional foot margin in inches.

Definition at line 869 of file Worksheet.php.

{
if (strlen($string) >= 255) {
//carp 'Footer string must be less than 255 characters';
return;
}
$this->_footer = $string;
$this->_margin_foot = $margin;
}
Spreadsheet_Excel_Writer_Worksheet::setHeader (   $string,
  $margin = 0.50 
)

Set the page header caption and optional margin.

public

Parameters
string$stringThe header text
float$marginoptional head margin in inches.

Definition at line 852 of file Worksheet.php.

{
if (strlen($string) >= 255) {
//carp 'Header string must be less than 255 characters';
return;
}
$this->_header = $string;
$this->_margin_head = $margin;
}
Spreadsheet_Excel_Writer_Worksheet::setHPagebreaks (   $breaks)

Store the horizontal page breaks on a worksheet (for printing).

The breaks represent the row after which the break is inserted.

public

Parameters
array$breaksArray containing the horizontal page breaks

Definition at line 1089 of file Worksheet.php.

{
foreach ($breaks as $break) {
array_push($this->_hbreaks, $break);
}
}
Spreadsheet_Excel_Writer_Worksheet::setInputEncoding (   $encoding)

Sets Input Encoding for writing strings.

public

Parameters
string$encodingThe encoding. Ex: 'UTF-16LE', 'utf-8', 'ISO-859-7'

Definition at line 1534 of file Worksheet.php.

References PEAR\raiseError().

{
if ($encoding != 'UTF-16LE' && !function_exists('iconv')) {
$this->raiseError("Using an input encoding other than UTF-16LE requires PHP support for iconv");
}
$this->_input_encoding = $encoding;
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setLandscape ( )

Set the page orientation as landscape.

public

Definition at line 828 of file Worksheet.php.

{
$this->_orientation = 0;
}
Spreadsheet_Excel_Writer_Worksheet::setMarginBottom (   $margin = 1.00)

Set the bottom margin in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 978 of file Worksheet.php.

Referenced by setMargins(), and setMargins_TB().

{
$this->_margin_bottom = $margin;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMarginLeft (   $margin = 0.75)

Set the left margin in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 945 of file Worksheet.php.

Referenced by setMargins(), and setMargins_LR().

{
$this->_margin_left = $margin;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMarginRight (   $margin = 0.75)

Set the right margin in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 956 of file Worksheet.php.

Referenced by setMargins(), and setMargins_LR().

{
$this->_margin_right = $margin;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMargins (   $margin)

Set all the page margins to the same value in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 907 of file Worksheet.php.

References setMarginBottom(), setMarginLeft(), setMarginRight(), and setMarginTop().

{
$this->setMarginLeft($margin);
$this->setMarginRight($margin);
$this->setMarginTop($margin);
$this->setMarginBottom($margin);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMargins_LR (   $margin)

Set the left and right margins to the same value in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 921 of file Worksheet.php.

References setMarginLeft(), and setMarginRight().

{
$this->setMarginLeft($margin);
$this->setMarginRight($margin);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMargins_TB (   $margin)

Set the top and bottom margins to the same value in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 933 of file Worksheet.php.

References setMarginBottom(), and setMarginTop().

{
$this->setMarginTop($margin);
$this->setMarginBottom($margin);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMarginTop (   $margin = 1.00)

Set the top margin in inches.

public

Parameters
float$marginThe margin to set in inches

Definition at line 967 of file Worksheet.php.

Referenced by setMargins(), and setMargins_TB().

{
$this->_margin_top = $margin;
}

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setMerge (   $first_row,
  $first_col,
  $last_row,
  $last_col 
)

Sets a merged cell range.

public

Parameters
integer$first_rowFirst row of the area to merge
integer$first_colFirst column of the area to merge
integer$last_rowLast row of the area to merge
integer$last_colLast column of the area to merge

Definition at line 682 of file Worksheet.php.

{
if (($last_row < $first_row) || ($last_col < $first_col)) {
return;
}
// don't check rowmin, rowmax, etc... because we don't know when this
// is going to be called
$this->_merged_ranges[] = array($first_row, $first_col, $last_row, $last_col);
}
Spreadsheet_Excel_Writer_Worksheet::setOutline (   $visible = true,
  $symbols_below = true,
  $symbols_right = true,
  $auto_style = false 
)

This method sets the properties for outlining and grouping.

The defaults correspond to Excel's defaults.

Parameters
bool$visible
bool$symbols_below
bool$symbols_right
bool$auto_style

Definition at line 1395 of file Worksheet.php.

{
$this->_outline_on = $visible;
$this->_outline_below = $symbols_below;
$this->_outline_right = $symbols_right;
$this->_outline_style = $auto_style;
// Ensure this is a boolean vale for Window2
if ($this->_outline_on) {
$this->_outline_on = 1;
}
}
Spreadsheet_Excel_Writer_Worksheet::setPaper (   $size = 0)

Set the paper type.

Ex. 1 = US Letter, 9 = A4

public

Parameters
integer$sizeThe type of paper size to use

Definition at line 839 of file Worksheet.php.

References $size.

{
$this->_paper_size = $size;
}
Spreadsheet_Excel_Writer_Worksheet::setPortrait ( )

Set the page orientation as portrait.

public

Definition at line 818 of file Worksheet.php.

{
$this->_orientation = 1;
}
Spreadsheet_Excel_Writer_Worksheet::setPrintScale (   $scale = 100)

Set the scale factor for the printed page.

It turns off the "fit to page" option

public

Parameters
integer$scaleThe optional scale factor. Defaults to 100

Definition at line 1135 of file Worksheet.php.

References PEAR\raiseError().

{
// Confine the scale to Excel's range
if ($scale < 10 || $scale > 400) {
$this->raiseError("Print scale $scale outside range: 10 <= zoom <= 400");
$scale = 100;
}
// Turn off "fit to page" option
$this->_fit_page = 0;
$this->_print_scale = floor($scale);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::setRow (   $row,
  $height,
  $format = null,
  $hidden = false,
  $level = 0 
)

This method is used to set the height and format for a row.

public

Parameters
integer$rowThe row to set
integer$heightHeight we are giving to the row. Use null to set XF without setting height
mixed$formatXF format we are giving to the row
bool$hiddenThe optional hidden attribute
integer$levelThe optional outline level for row, in range [0,7]

Definition at line 2143 of file Worksheet.php.

References $data, and $row.

{
$record = 0x0208; // Record identifier
$length = 0x0010; // Number of bytes to follow
$colMic = 0x0000; // First defined column
$colMac = 0x0000; // Last defined column
$irwMac = 0x0000; // Used by Excel to optimise loading
$reserved = 0x0000; // Reserved
$grbit = 0x0000; // Option flags
$ixfe = $this->_XF($format); // XF index
// set _row_sizes so _sizeRow() can use it
$this->_row_sizes[$row] = $height;
// Use setRow($row, null, $XF) to set XF format without setting height
if ($height != null) {
$miyRw = $height * 20; // row height
} else {
$miyRw = 0xff; // default row height is 256
}
$level = max(0, min($level, 7)); // level should be between 0 and 7
$this->_outline_row_level = max($level, $this->_outline_row_level);
// Set the options flags. fUnsynced is used to show that the font and row
// heights are not compatible. This is usually the case for WriteExcel.
// The collapsed flag 0x10 doesn't seem to be used to indicate that a row
// is collapsed. Instead it is used to indicate that the previous row is
// collapsed. The zero height flag, 0x20, is used to collapse a row.
$grbit |= $level;
if ($hidden) {
$grbit |= 0x0020;
}
$grbit |= 0x0040; // fUnsynced
if ($format) {
$grbit |= 0x0080;
}
$grbit |= 0x0100;
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvv", $row, $colMic, $colMac, $miyRw,
$irwMac,$reserved, $grbit, $ixfe);
$this->_append($header.$data);
}
Spreadsheet_Excel_Writer_Worksheet::setSelection (   $first_row,
  $first_column,
  $last_row,
  $last_column 
)

Set which cell or cells are selected in a worksheet.

public

Parameters
integer$first_rowfirst row in the selected quadrant
integer$first_columnfirst column in the selected quadrant
integer$last_rowlast row in the selected quadrant
integer$last_columnlast column in the selected quadrant

Definition at line 774 of file Worksheet.php.

{
$this->_selection = array($first_row,$first_column,$last_row,$last_column);
}
Spreadsheet_Excel_Writer_Worksheet::setValidation (   $row1,
  $col1,
  $row2,
  $col2,
$validator 
)

FIXME: add comments.

Definition at line 3487 of file Worksheet.php.

{
$this->_dv[] = $validator->_getData() .
pack("vvvvv", 1, $row1, $row2, $col1, $col2);
}
Spreadsheet_Excel_Writer_Worksheet::setVPagebreaks (   $breaks)

Store the vertical page breaks on a worksheet (for printing).

The breaks represent the column after which the break is inserted.

public

Parameters
array$breaksArray containing the vertical page breaks

Definition at line 1103 of file Worksheet.php.

{
foreach ($breaks as $break) {
array_push($this->_vbreaks, $break);
}
}
Spreadsheet_Excel_Writer_Worksheet::setZoom (   $scale = 100)

Set the worksheet zoom factor.

public

Parameters
integer$scaleThe zoom factor

Definition at line 1117 of file Worksheet.php.

References PEAR\raiseError().

{
// Confine the scale to Excel's range
if ($scale < 10 || $scale > 400) {
$this->raiseError("Zoom factor $scale outside range: 10 <= zoom <= 400");
$scale = 100;
}
$this->_zoom = floor($scale);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::Spreadsheet_Excel_Writer_Worksheet (   $BIFF_version,
  $name,
  $index,
$activesheet,
$firstsheet,
$str_total,
$str_unique,
$str_table,
$url_format,
$parser,
  $tmp_dir 
)

Constructor.

Parameters
string$nameThe name of the new worksheet
integer$indexThe index of the new worksheet
mixed&$activesheetThe current activesheet of the workbook we belong to
mixed&$firstsheetThe first worksheet in the workbook we belong to
mixed&$url_formatThe default format for hyperlinks
mixed&$parserThe formula parser created for the Workbook
string$tmp_dirThe path to the directory for temporary files private

Definition at line 370 of file Worksheet.php.

References $index, $name, _initialize(), and Spreadsheet_Excel_Writer_BIFFwriter\Spreadsheet_Excel_Writer_BIFFwriter().

{
// It needs to call its parent's constructor explicitly
$this->_BIFF_version = $BIFF_version;
$rowmax = 65536; // 16384 in Excel 5
$colmax = 256;
$this->name = $name;
$this->index = $index;
$this->activesheet = &$activesheet;
$this->firstsheet = &$firstsheet;
$this->_str_total = &$str_total;
$this->_str_unique = &$str_unique;
$this->_str_table = &$str_table;
$this->_url_format = &$url_format;
$this->_parser = &$parser;
//$this->ext_sheets = array();
$this->_filehandle = '';
$this->_using_tmpfile = true;
//$this->fileclosed = 0;
//$this->offset = 0;
$this->_xls_rowmax = $rowmax;
$this->_xls_colmax = $colmax;
$this->_xls_strmax = 255;
$this->_dim_rowmin = $rowmax + 1;
$this->_dim_rowmax = 0;
$this->_dim_colmin = $colmax + 1;
$this->_dim_colmax = 0;
$this->_colinfo = array();
$this->_selection = array(0,0,0,0);
$this->_panes = array();
$this->_active_pane = 3;
$this->_frozen = 0;
$this->selected = 0;
$this->_paper_size = 0x0;
$this->_orientation = 0x1;
$this->_header = '';
$this->_footer = '';
$this->_hcenter = 0;
$this->_vcenter = 0;
$this->_margin_head = 0.50;
$this->_margin_foot = 0.50;
$this->_margin_left = 0.75;
$this->_margin_right = 0.75;
$this->_margin_top = 1.00;
$this->_margin_bottom = 1.00;
$this->title_rowmin = null;
$this->title_rowmax = null;
$this->title_colmin = null;
$this->title_colmax = null;
$this->print_rowmin = null;
$this->print_rowmax = null;
$this->print_colmin = null;
$this->print_colmax = null;
$this->_print_gridlines = 1;
$this->_screen_gridlines = 1;
$this->_print_headers = 0;
$this->_fit_page = 0;
$this->_fit_width = 0;
$this->_fit_height = 0;
$this->_hbreaks = array();
$this->_vbreaks = array();
$this->_protect = 0;
$this->_password = null;
$this->col_sizes = array();
$this->_row_sizes = array();
$this->_zoom = 100;
$this->_print_scale = 100;
$this->_outline_row_level = 0;
$this->_outline_style = 0;
$this->_outline_below = 1;
$this->_outline_right = 1;
$this->_outline_on = 1;
$this->_merged_ranges = array();
$this->_input_encoding = '';
$this->_dv = array();
$this->_tmp_dir = $tmp_dir;
$this->_initialize();
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::thawPanes (   $panes)

Set panes and mark them as unfrozen.

public

Parameters
array$panesThis is the only parameter received and is composed of the following: 0 => Vertical split position, 1 => Horizontal split position 2 => Top row visible 3 => Leftmost column visible 4 => Active pane

Definition at line 807 of file Worksheet.php.

{
$this->_frozen = 0;
$this->_panes = $panes;
}
Spreadsheet_Excel_Writer_Worksheet::write (   $row,
  $col,
  $token,
  $format = null 
)

Map to the appropriate write method acording to the token recieved.

public

Parameters
integer$rowThe row of the cell we are writing to
integer$colThe column of the cell we are writing to
mixed$tokenWhat we are writing
mixed$formatThe optional format to apply to the cell

Definition at line 1158 of file Worksheet.php.

References $row, writeBlank(), writeFormula(), writeNumber(), writeString(), and writeUrl().

Referenced by writeCol(), and writeRow().

{
// Check for a cell reference in A1 notation and substitute row and column
/*if ($_[0] =~ /^\D/) {
@_ = $this->_substituteCellref(@_);
}*/
if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) {
// Match number
return $this->writeNumber($row, $col, $token, $format);
} elseif (preg_match("/^[fh]tt?p:\/\//", $token)) {
// Match http or ftp URL
return $this->writeUrl($row, $col, $token, '', $format);
} elseif (preg_match("/^mailto:/", $token)) {
// Match mailto:
return $this->writeUrl($row, $col, $token, '', $format);
} elseif (preg_match("/^(?:in|ex)ternal:/", $token)) {
// Match internal or external sheet link
return $this->writeUrl($row, $col, $token, '', $format);
} elseif (preg_match("/^=/", $token)) {
// Match formula
return $this->writeFormula($row, $col, $token, $format);
} elseif ($token == '') {
// Match blank
return $this->writeBlank($row, $col, $format);
} else {
// Default: match string
return $this->writeString($row, $col, $token, $format);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeBlank (   $row,
  $col,
  $format 
)

Write a blank cell to the specified row and column (zero indexed).

A blank cell is used to specify formatting without adding a string or a number.

A blank cell without a format serves no purpose. Therefore, we don't write a BLANK record unless a format is specified.

Returns 0 : normal termination (including no format) -1 : insufficient number of arguments -2 : row or column out of range

public

Parameters
integer$rowZero indexed row
integer$colZero indexed column
mixed$formatThe XF format

Definition at line 1702 of file Worksheet.php.

References $data, $header, $length, $record, $row, _append(), and _XF().

Referenced by write().

{
// Don't write a blank cell unless it has a format
if (!$format) {
return(0);
}
$record = 0x0201; // Record identifier
$length = 0x0006; // Number of bytes to follow
$xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax) {
return(-2);
}
if ($col >= $this->_xls_colmax) {
return(-2);
}
if ($row < $this->_dim_rowmin) {
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax) {
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin) {
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax) {
$this->_dim_colmax = $col;
}
$header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $xf);
$this->_append($header . $data);
return 0;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeCol (   $row,
  $col,
  $val,
  $format = null 
)

Write an array of values as a column.

public

Parameters
integer$rowThe first row (uppermost row) we are writing to
integer$colThe col we are writing to
array$valThe array of values to write
mixed$formatThe optional format to apply to the cell
Returns
mixed PEAR_Error on failure

Definition at line 1229 of file Worksheet.php.

References $row, and write().

Referenced by writeRow().

{
$retval = '';
if (is_array($val)) {
foreach ($val as $v) {
$this->write($row, $col, $v, $format);
$row++;
}
} else {
$retval = new PEAR_Error('$val needs to be an array');
}
return($retval);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeFormula (   $row,
  $col,
  $formula,
  $format = null 
)

Write a formula to the specified row and column (zero indexed).

The textual representation of the formula is passed to the parser in Parser.php which returns a packed binary string.

Returns 0 : normal termination -1 : formula errors (bad formula) -2 : row or column out of range

public

Parameters
integer$rowZero indexed row
integer$colZero indexed column
string$formulaThe formula text string
mixed$formatThe optional XF format
Returns
integer

Definition at line 1755 of file Worksheet.php.

References $data, $header, $length, $record, $row, _append(), _checkRowCol(), _XF(), PEAR\isError(), and writeString().

Referenced by write().

{
$record = 0x0006; // Record identifier
// Excel normally stores the last calculated value of the formula in $num.
// Clearly we are not in a position to calculate this a priori. Instead
// we set $num to zero and set the option flags in $grbit to ensure
// automatic calculation of the formula when the file is opened.
//
$xf = $this->_XF($format); // The cell format
$num = 0x00; // Current value of formula
$grbit = 0x03; // Option flags
$unknown = 0x0000; // Must be zero
// Check that row and col are valid and store max and min values
if ($this->_checkRowCol($row, $col) == false) {
return -2;
}
// Strip the '=' or '@' sign at the beginning of the formula string
if (preg_match("/^=/", $formula)) {
$formula = preg_replace("/(^=)/", "", $formula);
} elseif (preg_match("/^@/", $formula)) {
$formula = preg_replace("/(^@)/", "", $formula);
} else {
// Error handling
$this->writeString($row, $col, 'Unrecognised character for formula');
return -1;
}
// Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula);
if ($this->isError($error)) {
$this->writeString($row, $col, $error->getMessage());
return -1;
}
$formula = $this->_parser->toReversePolish();
if ($this->isError($formula)) {
$this->writeString($row, $col, $formula->getMessage());
return -1;
}
$formlen = strlen($formula); // Length of the binary string
$length = 0x16 + $formlen; // Length of the record data
$header = pack("vv", $record, $length);
$data = pack("vvvdvVv", $row, $col, $xf, $num,
$grbit, $unknown, $formlen);
$this->_append($header . $data . $formula);
return 0;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeNote (   $row,
  $col,
  $note 
)

Writes a note associated with the cell given by the row and column.

NOTE records don't have a length limit.

public

Parameters
integer$rowZero indexed row
integer$colZero indexed column
string$noteThe note to write

Definition at line 1642 of file Worksheet.php.

References $data, $header, $length, $record, $row, and _append().

{
$note_length = strlen($note);
$record = 0x001C; // Record identifier
$max_length = 2048; // Maximun length for a NOTE record
//$length = 0x0006 + $note_length; // Bytes to follow
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax) {
return(-2);
}
if ($col >= $this->_xls_colmax) {
return(-2);
}
if ($row < $this->_dim_rowmin) {
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax) {
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin) {
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax) {
$this->_dim_colmax = $col;
}
// 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);
$this->_append($header . $data . substr($note, 0, 2048));
for ($i = $max_length; $i < $note_length; $i += $max_length) {
$chunk = substr($note, $i, $max_length);
$length = 0x0006 + strlen($chunk);
$header = pack("vv", $record, $length);
$data = pack("vvv", -1, 0, strlen($chunk));
$this->_append($header.$data.$chunk);
}
return(0);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeNumber (   $row,
  $col,
  $num,
  $format = null 
)

Write a double to the specified row and column (zero indexed).

An integer can be written as a double. Excel will display an integer. $format is optional.

Returns 0 : normal termination -2 : row or column out of range

public

Parameters
integer$rowZero indexed row
integer$colZero indexed column
float$numThe number to write
mixed$formatThe optional XF format
Returns
integer

Definition at line 1430 of file Worksheet.php.

References $data, $header, $length, $record, $row, _append(), and _XF().

Referenced by write().

{
$record = 0x0203; // Record identifier
$length = 0x000E; // Number of bytes to follow
$xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax) {
return(-2);
}
if ($col >= $this->_xls_colmax) {
return(-2);
}
if ($row < $this->_dim_rowmin) {
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax) {
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin) {
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax) {
$this->_dim_colmax = $col;
}
$header = pack("vv", $record, $length);
$data = pack("vvv", $row, $col, $xf);
$xl_double = pack("d", $num);
if ($this->_byte_order) { // if it's Big Endian
$xl_double = strrev($xl_double);
}
$this->_append($header.$data.$xl_double);
return(0);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeRow (   $row,
  $col,
  $val,
  $format = null 
)

Write an array of values as a row.

public

Parameters
integer$rowThe row we are writing to
integer$colThe first col (leftmost col) we are writing to
array$valThe array of values to write
mixed$formatThe optional format to apply to the cell
Returns
mixed PEAR_Error on failure

Definition at line 1200 of file Worksheet.php.

References $row, write(), and writeCol().

{
$retval = '';
if (is_array($val)) {
foreach ($val as $v) {
if (is_array($v)) {
$this->writeCol($row, $col, $v, $format);
} else {
$this->write($row, $col, $v, $format);
}
$col++;
}
} else {
$retval = new PEAR_Error('$val needs to be an array');
}
return($retval);
}

+ Here is the call graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeString (   $row,
  $col,
  $str,
  $format = null 
)

Write a string to the specified row and column (zero indexed).

NOTE: there is an Excel 5 defined limit of 255 characters. $format is optional. Returns 0 : normal termination -2 : row or column out of range -3 : long string truncated to 255 chars

public

Parameters
integer$rowZero indexed row
integer$colZero indexed column
string$strThe string to write
mixed$formatThe XF format for the cell
Returns
integer

Definition at line 1483 of file Worksheet.php.

References $_xls_strmax, $data, $header, $length, $record, $row, $str_error, _append(), _XF(), and writeStringBIFF8().

Referenced by _writeUrlInternal(), _writeUrlWeb(), write(), and writeFormula().

{
if ($this->_BIFF_version == 0x0600) {
return $this->writeStringBIFF8($row, $col, $str, $format);
}
$strlen = strlen($str);
$record = 0x0204; // Record identifier
$length = 0x0008 + $strlen; // Bytes to follow
$xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values
if ($row >= $this->_xls_rowmax) {
return(-2);
}
if ($col >= $this->_xls_colmax) {
return(-2);
}
if ($row < $this->_dim_rowmin) {
$this->_dim_rowmin = $row;
}
if ($row > $this->_dim_rowmax) {
$this->_dim_rowmax = $row;
}
if ($col < $this->_dim_colmin) {
$this->_dim_colmin = $col;
}
if ($col > $this->_dim_colmax) {
$this->_dim_colmax = $col;
}
if ($strlen > $this->_xls_strmax) { // LABEL must be < 255 chars
$str = substr($str, 0, $this->_xls_strmax);
$strlen = $this->_xls_strmax;
$str_error = -3;
}
$header = pack("vv", $record, $length);
$data = pack("vvvv", $row, $col, $xf, $strlen);
$this->_append($header . $data . $str);
return($str_error);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeStringBIFF8 (   $row,
  $col,
  $str,
  $format = null 
)

Write a string to the specified row and column (zero indexed).

This is the BIFF8 version (no 255 chars limit). $format is optional. Returns 0 : normal termination -2 : row or column out of range -3 : long string truncated to 255 chars

public

Parameters
integer$rowZero indexed row
integer$colZero indexed column
string$strThe string to write
mixed$formatThe XF format for the cell
Returns
integer

Definition at line 1557 of file Worksheet.php.

References $data, $header, $length, $record, $row, $str_error, _append(), _checkRowCol(), and _XF().

Referenced by writeString().

{
if ($this->_input_encoding == 'UTF-16LE')
{
$strlen = function_exists('mb_strlen') ? mb_strlen($str, 'UTF-16LE') : (strlen($str) / 2);
$encoding = 0x1;
}
elseif ($this->_input_encoding != '')
{
$str = iconv($this->_input_encoding, 'UTF-16LE', $str);
$strlen = function_exists('mb_strlen') ? mb_strlen($str, 'UTF-16LE') : (strlen($str) / 2);
$encoding = 0x1;
}
else
{
$strlen = strlen($str);
$encoding = 0x0;
}
$record = 0x00FD; // Record identifier
$length = 0x000A; // Bytes to follow
$xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values
if ($this->_checkRowCol($row, $col) == false) {
return -2;
}
$str = pack('vC', $strlen, $encoding).$str;
/* check if string is already present */
if (!isset($this->_str_table[$str])) {
$this->_str_table[$str] = $this->_str_unique++;
}
$this->_str_total++;
$header = pack('vv', $record, $length);
$data = pack('vvvV', $row, $col, $xf, $this->_str_table[$str]);
$this->_append($header.$data);
return $str_error;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Spreadsheet_Excel_Writer_Worksheet::writeUrl (   $row,
  $col,
  $url,
  $string = '',
  $format = null 
)

Write a hyperlink.

This is comprised of two elements: the visible label and the invisible link. The visible label is the same as the link unless an alternative string is specified. The label is written using the writeString() method. Therefore the 255 characters string limit applies. $string and $format are optional.

The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external directory url.

Returns 0 : normal termination -2 : row or column out of range -3 : long string truncated to 255 chars

public

Parameters
integer$rowRow
integer$colColumn
string$urlURL string
string$stringAlternative label
mixed$formatThe cell format
Returns
integer

Definition at line 1833 of file Worksheet.php.

References $row, $url, and _writeUrlRange().

Referenced by write().

{
// Add start row and col to arg list
return($this->_writeUrlRange($row, $col, $row, $col, $url, $string, $format));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

Spreadsheet_Excel_Writer_Worksheet::$_active_pane

Definition at line 152 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_colinfo

Definition at line 134 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_dim_colmax

Definition at line 128 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_dim_colmin

Definition at line 121 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_dim_rowmax

Definition at line 114 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_dim_rowmin

Definition at line 107 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_filehandle

Definition at line 76 of file Worksheet.php.

Referenced by getData().

Spreadsheet_Excel_Writer_Worksheet::$_fit_height

Definition at line 326 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_fit_page

Definition at line 314 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_fit_width

Definition at line 320 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_footer

Definition at line 188 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_frozen

Definition at line 158 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_hcenter

Definition at line 194 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_header

Definition at line 182 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_input_encoding

Definition at line 356 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_margin_bottom

Definition at line 236 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_margin_foot

Definition at line 212 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_margin_head

Definition at line 206 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_margin_left

Definition at line 218 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_margin_right

Definition at line 224 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_margin_top

Definition at line 230 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_merged_ranges

Definition at line 350 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_orientation

Definition at line 176 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_outline_below

Definition at line 296 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_outline_on

Definition at line 284 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_outline_right

Definition at line 302 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_outline_row_level

Definition at line 308 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_outline_style

Definition at line 290 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_panes

Definition at line 146 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_paper_size

Definition at line 170 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_parser

Definition at line 70 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_selection

Definition at line 140 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_str_table

Definition at line 344 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_str_total

Definition at line 332 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_str_unique

Definition at line 338 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_url_format

Definition at line 64 of file Worksheet.php.

Referenced by _writeUrlInternal(), and _writeUrlWeb().

Spreadsheet_Excel_Writer_Worksheet::$_using_tmpfile

Definition at line 82 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_vcenter

Definition at line 200 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_xls_colmax

Definition at line 94 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_xls_rowmax

Definition at line 88 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$_xls_strmax

Definition at line 100 of file Worksheet.php.

Referenced by writeString().

if (($str_error==-2) or($str_error==-3)) Spreadsheet_Excel_Writer_Worksheet::$absolute = 0x02

Definition at line 2047 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$data
Spreadsheet_Excel_Writer_Worksheet::$dir_long = $url

Definition at line 2074 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$dir_long_len = pack("V", strlen($dir_long) )

Definition at line 2097 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$dir_short = "\0"

Definition at line 2089 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$dir_short_len = pack("V", strlen($dir_short) )

Definition at line 2096 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$header = pack("vv", $record, $length)
Spreadsheet_Excel_Writer_Worksheet::$index

Definition at line 58 of file Worksheet.php.

Referenced by activate(), setFirstSheet(), and Spreadsheet_Excel_Writer_Worksheet().

Spreadsheet_Excel_Writer_Worksheet::$length = 0x00000
if (!preg_match("/\\\/", $url)) if (preg_match("/^\.\.\\\/", $url) Spreadsheet_Excel_Writer_Worksheet::$link_type) = 0x01 | $absolute

Definition at line 2054 of file Worksheet.php.

if (preg_match("/\#/", $url)) Spreadsheet_Excel_Writer_Worksheet::$link_type = pack("V", $link_type)

Definition at line 2082 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$name

Definition at line 52 of file Worksheet.php.

Referenced by getName(), and Spreadsheet_Excel_Writer_Worksheet().

Spreadsheet_Excel_Writer_Worksheet::$print_colmax

Definition at line 278 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$print_colmin

Definition at line 272 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$print_rowmax

Definition at line 266 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$print_rowmin

Definition at line 260 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$record = 0x01B8
Spreadsheet_Excel_Writer_Worksheet::$selected

Definition at line 164 of file Worksheet.php.

if ($str== '') Spreadsheet_Excel_Writer_Worksheet::$str_error = $this->writeString($row1, $col1, $str, $format)

Definition at line 2037 of file Worksheet.php.

Referenced by _writeUrlInternal(), _writeUrlWeb(), writeString(), and writeStringBIFF8().

Spreadsheet_Excel_Writer_Worksheet::$stream_len = pack("V", 0)

Definition at line 2098 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$title_colmin

Definition at line 254 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$title_rowmax

Definition at line 248 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$title_rowmin

Definition at line 242 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' )

Definition at line 2101 of file Worksheet.php.

Referenced by _writeUrlInternal(), and _writeUrlWeb().

Spreadsheet_Excel_Writer_Worksheet::$unknown2 = pack("H*",'0303000000000000C000000000000046' )

Definition at line 2102 of file Worksheet.php.

Referenced by _writeUrlWeb().

Spreadsheet_Excel_Writer_Worksheet::$unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000')

Definition at line 2103 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$unknown4 = pack("v", 0x03 )

Definition at line 2104 of file Worksheet.php.

Spreadsheet_Excel_Writer_Worksheet::$up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless)

Definition at line 2085 of file Worksheet.php.

if (!$format) Spreadsheet_Excel_Writer_Worksheet::$url = preg_replace('/^external:/', '', $url)

Definition at line 2030 of file Worksheet.php.

Referenced by _writeUrlInternal(), _writeUrlRange(), _writeUrlWeb(), and writeUrl().

Spreadsheet_Excel_Writer_Worksheet::$url = preg_replace('/\//', "\\", $url)

Definition at line 2031 of file Worksheet.php.


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