Class Spreadsheet_Excel_Writer_Workbook

Description

Class for generating Excel Spreadsheets

Located in /libraries/pear/Spreadsheet/Excel/Writer/Workbook.php (line 50)

PEAR
   |
   --Spreadsheet_Excel_Writer_BIFFwriter
      |
      --Spreadsheet_Excel_Writer_Workbook
Direct descendents
Class Description
 class Spreadsheet_Excel_Writer Class for writing Excel Spreadsheets. This class should change COMPLETELY.
Variable Summary
 integer $_1904
 integer $_activesheet
 integer $_biffsize
 integer $_codepage
 integer $_country_code
 integer $_fileclosed
 string $_filename
 integer $_firstsheet
 array $_formats
 array $_palette
 object Parser $_parser
 integer $_selected
 string $_sheetname
 array $_sheetnames
 string $_tmp_dir
 object Format $_tmp_format
 object Format $_url_format
 array $_worksheets
 integer $_xf_index
Method Summary
 Spreadsheet_Excel_Writer_Workbook Spreadsheet_Excel_Writer_Workbook (string $filename)
 &Spreadsheet_Excel_Writer_Format &addFormat ([array $properties = array()])
 &Spreadsheet_Excel_Writer_Validator &addValidator ()
 mixed &addWorksheet ([string $name = ''])
 mixed close ()
 void setCountry (integer $code)
 integer setCustomColor (integer $index, integer $red, integer $green, integer $blue)
 true setTempDir (string $dir)
 void setVersion (integer $version)
 array sheets ()
 array worksheets ()
 void _setPaletteXl97 ()
 void _storeAllFonts ()
 void _storeAllStyles ()
 void _storeAllXfs ()
 void _storeBoundsheet (string $sheetname, integer $offset)
 void _storeCodepage ()
 void _storeCountry ()
 void _storeDatemode ()
 void _storeExterncount (integer $cxals)
 void _storeExterns ()
 void _storeExternsheet (string $sheetname)
 void _storeExternsheetBiff8 (string $sheetname)
 void _storeNameLong (integer $index, integer $type, integer $rowmin, integer $rowmax, integer $colmin, integer $colmax)
 void _storeNames ()
 void _storeNameShort (integer $index, integer $type, integer $rowmin, integer $rowmax, integer $colmin, integer $colmax)
 void _storeNumFormat (string $format, integer $ifmt)
 mixed _storeOLEFile ()
 void _storePalette ()
 void _storeStyle ()
 void _storeWindow1 ()
 mixed _storeWorkbook ()
Variables
integer $_1904 (line 68)

Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904)

integer $_activesheet (line 74)

The active worksheet of the workbook (0 indexed)

integer $_biffsize (line 106)

The BIFF file size for the workbook.

integer $_codepage (line 154)

The codepage indicates the text encoding used for strings

integer $_country_code (line 160)

The country code used for localization

integer $_fileclosed (line 99)

Flag for preventing close from being called twice.

string $_filename (line 56)

Filename for the Workbook

integer $_firstsheet (line 80)

1st displayed worksheet in the workbook (0 indexed)

array $_formats (line 136)

Array containing references to all of this workbook's formats

array $_palette (line 142)

Array containing the colour palette

object Parser $_parser (line 62)

Formula parser

integer $_selected (line 86)

Number of workbook tabs selected

string $_sheetname (line 112)

The default sheetname for all sheets created.

array $_sheetnames (line 130)

Array of sheetnames for creating the EXTERNSHEET records

integer $_string_sizeinfo_size (line 172)

number of bytes for sizeinfo of strings

string $_tmp_dir (line 166)

The temporary dir for storing the OLE file

object Format $_tmp_format (line 118)

The default XF format.

object Format $_url_format (line 148)

The default format for URLs.

array $_worksheets (line 124)

Array containing references to all of this workbook's worksheets

integer $_xf_index (line 92)

Index for creating adding new formats to the workbook

Inherited Variables

Inherited from Spreadsheet_Excel_Writer_BIFFwriter

Spreadsheet_Excel_Writer_BIFFwriter::$_BIFF_version
Spreadsheet_Excel_Writer_BIFFwriter::$_byte_order
Spreadsheet_Excel_Writer_BIFFwriter::$_data
Spreadsheet_Excel_Writer_BIFFwriter::$_datasize
Spreadsheet_Excel_Writer_BIFFwriter::$_limit
Methods
Constructor Spreadsheet_Excel_Writer_Workbook (line 180)

Class constructor

  • access: public
Spreadsheet_Excel_Writer_Workbook Spreadsheet_Excel_Writer_Workbook (string $filename)
  • string $filename: filename for storing the workbook. "-" for writing to stdout.
addFormat (line 358)

Add a new format to the Excel workbook.

Also, pass any properties to the Format constructor.

  • return: reference to an Excel Format
  • access: public
&Spreadsheet_Excel_Writer_Format &addFormat ([array $properties = array()])
  • array $properties: array with properties for initializing the format.
addValidator (line 372)

Create new validator.

  • return: reference to a Validator
  • access: public
&Spreadsheet_Excel_Writer_Validator &addValidator ()
addWorksheet (line 314)

Add a new worksheet to the Excel workbook.

If no name is given the name of the worksheet will be Sheeti$i, with $i in [1..].

  • return: reference to a worksheet object on success, PEAR_Error on failure
  • access: public
mixed &addWorksheet ([string $name = ''])
  • string $name: the optional name of the worksheet
close (line 220)

Calls finalization methods.

This method should always be the last one to be called on every workbook

  • return: true on success. PEAR_Error on failure
  • access: public
mixed close ()
setCountry (line 299)

Set the country identifier for the workbook

  • access: public
void setCountry (integer $code)
  • integer $code: Is the international calling country code for the chosen country.
setCustomColor (line 390)

Change the RGB components of the elements in the colour palette.

  • return: The palette index for the custom color
  • access: public
integer setCustomColor (integer $index, integer $red, integer $green, integer $blue)
  • integer $index: colour index
  • integer $red: red RGB value [0-255]
  • integer $green: green RGB value [0-255]
  • integer $blue: blue RGB value [0-255]
setTempDir (line 565)

Sets the temp dir used for storing the OLE file

  • return: if given dir is valid, false otherwise
  • access: public
true setTempDir (string $dir)
  • string $dir: The dir to be used as temp dir
setVersion (line 269)

Sets the BIFF version.

This method exists just to access experimental functionality from BIFF8. It will be deprecated ! Only possible value is 8 (Excel 97/2000). For any other value it fails silently.

  • access: public
void setVersion (integer $version)
  • integer $version: The BIFF version
sheets (line 242)

An accessor for the _worksheets[] array Returns an array of the worksheet objects in a workbook It actually calls to worksheets()

array sheets ()
worksheets (line 254)

An accessor for the _worksheets[] array.

Returns an array of the worksheet objects in a workbook

  • access: public
array worksheets ()
_calcSheetOffsets (line 614)

Calculate offsets for Worksheet BOF records.

  • access: private
void _calcSheetOffsets ()
_calculateSharedStringsSizes (line 1316)

Calculate

Handling of the SST continue blocks is complicated by the need to include an additional continuation byte depending on whether the string is split between blocks or whether it starts at the beginning of the block. (There are also additional complications that will arise later when/if Rich Strings are supported).

  • access: private
void _calculateSharedStringsSizes ()
_setPaletteXl97 (line 423)

Sets the colour palette to the Excel 97+ default.

  • access: private
void _setPaletteXl97 ()
_storeAllFonts (line 654)

Store the Excel FONT records.

  • access: private
void _storeAllFonts ()
_storeAllNumFormats (line 700)

Store user defined numerical formats i.e. FORMAT records

  • access: private
void _storeAllNumFormats ()
_storeAllStyles (line 778)

Write all STYLE records.

  • access: private
void _storeAllStyles ()
_storeAllXfs (line 751)

Write all XF records.

  • access: private
void _storeAllXfs ()
_storeBoundsheet (line 939)

Writes Excel BIFF BOUNDSHEET record.

FIXME: inconsistent with BIFF documentation

  • access: private
void _storeBoundsheet (string $sheetname, integer $offset)
  • string $sheetname: Worksheet name
  • integer $offset: Location of worksheet BOF
_storeCodepage (line 889)

Stores the CODEPAGE biff record.

  • access: private
void _storeCodepage ()
_storeCountry (line 1269)

Stores the COUNTRY record for localization

  • access: private
void _storeCountry ()
_storeDatemode (line 1055)

Write DATEMODE record to indicate the date system in use (1904 or 1900).

  • access: private
void _storeDatemode ()
_storeExterncount (line 1081)

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

Excel only stores references to external sheets that are used in NAME. The workbook NAME record is required to define the print area and the repeat rows and columns.

A similar method is used in Worksheet.php for a slightly different purpose.

  • access: private
void _storeExterncount (integer $cxals)
  • integer $cxals: Number of external references
_storeExterns (line 789)

Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for the NAME records.

  • access: private
void _storeExterns ()
_storeExternsheet (line 1102)

Writes the Excel BIFF EXTERNSHEET record. These references are used by formulas. NAME record is required to define the print area and the repeat rows and columns.

A similar method is used in Worksheet.php for a slightly different purpose.

  • access: private
void _storeExternsheet (string $sheetname)
  • string $sheetname: Worksheet name
_storeExternsheetBiff8 (line 984)

Writes the Excel BIFF EXTERNSHEET record. These references are used by formulas.

  • access: private
void _storeExternsheetBiff8 (string $sheetname)
  • string $sheetname: Worksheet name
_storeNameLong (line 1194)

Store the NAME record in the long format that is used for storing the repeat rows and columns when both are specified. This shares a lot of code with _storeNameShort() but we use a separate method to keep the code clean.

Code abstraction for reuse can be carried too far, and I should know. ;-)

  • access: private
void _storeNameLong (integer $index, integer $type, integer $rowmin, integer $rowmax, integer $colmin, integer $colmax)
  • integer $index: Sheet index
  • integer $type: Built-in name type
  • integer $rowmin: Start row
  • integer $rowmax: End row
  • integer $colmin: Start colum
  • integer $colmax: End column
_storeNames (line 805)

Write the NAME record to define the print area and the repeat rows and cols.

  • access: private
void _storeNames ()
_storeNameShort (line 1128)

Store the NAME record in the short format that is used for storing the print area, repeat rows only and repeat columns only.

  • access: private
void _storeNameShort (integer $index, integer $type, integer $rowmin, integer $rowmax, integer $colmin, integer $colmax)
  • integer $index: Sheet index
  • integer $type: Built-in name type
  • integer $rowmin: Start row
  • integer $rowmax: End row
  • integer $colmin: Start colum
  • integer $colmax: End column
_storeNumFormat (line 1026)

Writes Excel FORMAT record for non "built-in" numerical formats.

  • access: private
void _storeNumFormat (string $format, integer $ifmt)
  • string $format: Custom format string
  • integer $ifmt: Format index code
_storeOLEFile (line 580)

Store the workbook in an OLE container

  • return: true on success. PEAR_Error on failure
  • access: private
mixed _storeOLEFile ()
_storePalette (line 1285)

Stores the PALETTE biff record.

  • access: private
void _storePalette ()
_storeSharedStringsTable (line 1434)

Write all of the workbooks strings into an indexed array.

See the comments in _calculate_shared_string_sizes() for more information.

The Excel documentation says that the SST record should be followed by an EXTSST record. The EXTSST record is a hash table that is used to optimise access to SST. However, despite the documentation it doesn't seem to be required so we will ignore it.

  • access: private
void _storeSharedStringsTable ()
_storeStyle (line 1004)

Write Excel BIFF STYLE records.

  • access: private
void _storeStyle ()
_storeSupbookInternal (line 967)

Write Internal SUPBOOK record

  • access: private
void _storeSupbookInternal ()
_storeWindow1 (line 906)

Write Excel BIFF WINDOW1 record.

  • access: private
void _storeWindow1 ()
_storeWorkbook (line 492)

Assemble worksheets into a workbook and send the BIFF data to an OLE storage.

  • return: true on success. PEAR_Error on failure
  • access: private
mixed _storeWorkbook ()

Inherited Methods

Inherited From Spreadsheet_Excel_Writer_BIFFwriter

 Spreadsheet_Excel_Writer_BIFFwriter::Spreadsheet_Excel_Writer_BIFFwriter()
 Spreadsheet_Excel_Writer_BIFFwriter::_addContinue()
 Spreadsheet_Excel_Writer_BIFFwriter::_append()
 Spreadsheet_Excel_Writer_BIFFwriter::_prepend()
 Spreadsheet_Excel_Writer_BIFFwriter::_setByteOrder()
 Spreadsheet_Excel_Writer_BIFFwriter::_storeBof()
 Spreadsheet_Excel_Writer_BIFFwriter::_storeEof()

Documentation generated on Fri, 11 Feb 2005 18:14:39 +0000 by phpDocumentor 1.3.0RC3