Structures_DataGrid_Renderer_XLS
[ class tree: Structures_DataGrid_Renderer_XLS ] [ index: Structures_DataGrid_Renderer_XLS ] [ all elements ]

Class: Structures_DataGrid_Renderer_XLS

Source Location: /Structures_DataGrid_Renderer_XLS-0.1.3/DataGrid/Renderer/XLS.php

Class Overview

Structures_DataGrid_Renderer
   |
   --Structures_DataGrid_Renderer_XLS

Excel Spreadsheet Rendering Driver


Author(s):

Version:

  • $Revision: 1.49 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 151]
Excel Spreadsheet Rendering Driver

SUPPORTED OPTIONS:

  • headerFormat: (mixed) The format for header cells (either 0 [= "no format"] or a Spreadsheet_Excel_Writer_Format object) Please see the NOTE ABOUT FORMATTING below.
  • bodyFormat: (mixed) The format for body cells (either 0 [= "no format"] or a Spreadsheet_Excel_Writer_Format object) Please see the NOTE ABOUT FORMATTING below.
  • filename: (string) The filename of the spreadsheet
  • sendToBrowser: (bool) Should the spreadsheet be send to the browser? (true = send to browser, false = write to a file)
  • tempDir: (string) A temporary directory to be used by Spreadsheet_Excel_Writer (cp. "General Notes" section).
  • version: (int) If you don't pass a worksheet object to this renderer, you can set the BIFF version with this option. The only accepted value by Spreadsheet_Excel_Writer is 8 (for usage of the BIFF8 format). All other values will lead to the older format (which is needed if you get errors in Excel, e.g. about a broken file).
  • worksheet: (object) Optional reference to a Spreadsheet_Excel_Writer_Worksheet object. You can leave this to null except if your workbook contains several worksheets and you want to fill a specific one.
  • startCol: (int) The Worksheet column number to start rendering at
  • startRow: (int) The Worksheet row number to start rendering at
  • border: (int) Border drawn around the whole datagrid: 0 => none, 1 => thin, 2 => thick (NOT IMPLEMENTED YET)
  • headerBorder: (int) Border between the header and body: 0 => none, 1 => thin, 2 => thick (NOT IMPLEMENTED YET)
  • columnAttributes: (-) IGNORED
  • onMove: (-) IGNORED
  • onMoveData: (-) IGNORED
SUPPORTED OPERATION MODES:

  • Container Support: yes
  • Output Buffering: no
  • Direct Rendering: not really, see below
  • Streaming: no
  • Object Preserving: no
GENERAL NOTES:

This driver does not support the flatten() method. You can not retrieve its output with DataGrid::getOutput(). You can either render it directly to the browser or save it to a file. See the "sendToBrowser" and "filename" options.

This driver has container support. You can use Structures_DataGrid::fill() with it; that's even recommended.

If PHP's safe_mode is enabled, Spreadsheet_Excel_Writer sometimes fails to generate the Excel file. You can avoid this problem by setting the 'tempDir' option to a (temporary) directory that is writable by PHP.

NOTE ABOUT FORMATTING:

You can specify some formatting with the 'headerFormat' and 'bodyFormat' options, or with setBodyFormat() and setHeaderFormat().

But beware of the following from the Spreadsheet_Excel_Writer manual: "Formats can't be created directly by a new call. You have to create a format using the addFormat() method from a Workbook, which associates your Format with this Workbook (you can't use the Format with another Workbook)."

What this means is that if you want to pass a format to this driver you have to "derive" the Format object out of the workbook used in the driver.

The easiest way to do this is:

  1.  // Create a workbook
  2.  $workbook = new Spreadsheet_Excel_Writer();
  3.  
  4.  // Specify that spreadsheet must be sent the browser
  5.  $workbook->send('test.xls');
  6.  
  7.  // Create your format
  8.  $format_bold =$workbook->addFormat();
  9.  $format_bold->setBold();
  10.  
  11.  // Fill the workbook, passing the format as an option
  12.  $options = array('headerFormat' => &$format_bold);
  13.  $datagrid->fill($workbook$options);



[ Top ]


Method Detail

Structures_DataGrid_Renderer_XLS (Constructor)   [line 181]

Structures_DataGrid_Renderer_XLS Structures_DataGrid_Renderer_XLS( )

Constructor

Build default values

  • Access: public

[ Top ]

buildHeader   [line 348]

void buildHeader( $columns)

Handles building the header of the table
  • Access: protected

Parameters:

   $columns   — 

[ Top ]

buildRow   [line 366]

void buildRow( int $index, array $data)

Build a body row
  • Access: protected

Parameters:

int   $index   —  Row index
array   $data   —  Record data

[ Top ]

getContainer   [line 220]

object Spreadsheet_Excel_Writer &getContainer( )

Return a reference to the Spreadsheet_Excel_Writer object
  • Return: or PEAR_Error
  • Access: public

[ Top ]

getSpreadsheet   [line 337]

void &getSpreadsheet( )

Get the spreadsheet object
  • Access: public

[ Top ]

init   [line 231]

void init( )

Instantiate the container if needed, and set it up
  • Access: protected

[ Top ]

render   [line 382]

mixed render( )

Output the datagrid or save it to a file
  • Return: True or PEAR_Error
  • Access: protected

[ Top ]

setBodyFormat   [line 327]

void setBodyFormat( &$format, object $format)

Set body format

Please see the "NOTE ABOUT FORMATTING" in this class documentation


Parameters:

object   $format   —  Spreadsheet_Excel_Writer_Format object
   &$format   — 

[ Top ]

setContainer   [line 208]

mixed setContainer( &$workbook, object $workbook)

Attach an already instantiated Spreadsheet_Excel_Writer object
  • Return: True or a PEAR_Error
  • Access: public

Parameters:

object   $workbook   —  Spreadsheet_Excel_Writer
   &$workbook   — 

[ Top ]

setCustomWriter   [line 300]

void setCustomWriter( &$workbook, &$worksheet, object $workbook, object $worksheet)

Replace the internal Excel Writer with a custom one

It is recommended to use setContainer() or Structures_DataGrid::fill() and the "worksheet" option instead of this method.

This is useful in order to customize your new XLS document before Structures_DataGrid fills it with data.

This method is incompatible with setFilename()


Parameters:

object   $workbook   —  Spreadsheet_Excel_Writer_Workbook object
object   $worksheet   —  Spreadsheet_Excel_Writer_Worksheet object (optional)
   &$workbook   — 
   &$worksheet   — 

[ Top ]

setFilename   [line 278]

void setFilename( [string $filename = 'spreadsheet.xls'], [bool $sendToBrowser = true])

Sets the name of the file to create

This is incompatible with the setCustomWriter() method


Parameters:

string   $filename   —  The name of the file
bool   $sendToBrowser   —  Whether the spreadsheet should be send to the browser or written to a file

[ Top ]

setHeaderFormat   [line 314]

void setHeaderFormat( &$format, object $format)

Set headers format

Please see the "NOTE ABOUT FORMATTING" in this class documentation


Parameters:

object   $format   —  Spreadsheet_Excel_Writer_Format object
   &$format   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:14:15 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.