remove underscore from public attributes

git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@112181 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Xavier Noguer Gallego 2003-01-16 22:32:10 +00:00
parent a900104e34
commit b18e2e8525
2 changed files with 397 additions and 153 deletions

View File

@ -296,8 +296,8 @@ class Workbook extends BIFFwriter
} }
// Check that the colour components are in the right range // Check that the colour components are in the right range
if ( ($red < 0 or $red > 255) || if ( ($red < 0 or $red > 255) or
($green < 0 or $green > 255) || ($green < 0 or $green > 255) or
($blue < 0 or $blue > 255) ) ($blue < 0 or $blue > 255) )
{ {
$this->raiseError("Color component outside range: 0 <= color <= 255"); $this->raiseError("Color component outside range: 0 <= color <= 255");
@ -630,15 +630,15 @@ class Workbook extends BIFFwriter
// Create the print area NAME records // Create the print area NAME records
foreach ($this->_worksheets as $worksheet) { foreach ($this->_worksheets as $worksheet) {
// Write a Name record if the print area has been defined // Write a Name record if the print area has been defined
if (isset($worksheet->_print_rowmin)) if (isset($worksheet->print_rowmin))
{ {
$this->_storeNameShort( $this->_storeNameShort(
$worksheet->index, $worksheet->index,
0x06, // NAME type 0x06, // NAME type
$worksheet->_print_rowmin, $worksheet->print_rowmin,
$worksheet->_print_rowmax, $worksheet->print_rowmax,
$worksheet->_print_colmin, $worksheet->print_colmin,
$worksheet->_print_colmax $worksheet->print_colmax
); );
} }
} }
@ -646,15 +646,15 @@ class Workbook extends BIFFwriter
// Create the print title NAME records // Create the print title NAME records
foreach ($this->_worksheets as $worksheet) foreach ($this->_worksheets as $worksheet)
{ {
$rowmin = $worksheet->_title_rowmin; $rowmin = $worksheet->title_rowmin;
$rowmax = $worksheet->_title_rowmax; $rowmax = $worksheet->title_rowmax;
$colmin = $worksheet->_title_colmin; $colmin = $worksheet->title_colmin;
$colmax = $worksheet->_title_colmax; $colmax = $worksheet->title_colmax;
// Determine if row + col, row, col or nothing has been defined // Determine if row + col, row, col or nothing has been defined
// and write the appropriate record // and write the appropriate record
// //
if (isset($rowmin) && isset($colmin)) { if (isset($rowmin) and isset($colmin)) {
// Row and column titles have been defined. // Row and column titles have been defined.
// Row title has been defined. // Row title has been defined.
$this->_storeNameLong( $this->_storeNameLong(

View File

@ -44,6 +44,243 @@ require_once('Spreadsheet/Excel/Writer/BIFFwriter.php');
class Worksheet extends BIFFwriter class Worksheet extends BIFFwriter
{ {
/**
* Name of the Worksheet
* @var string
*/
var $name;
/**
* Index for the Worksheet
* @var integer
*/
var $index;
/**
* Reference to the (default) Format object for URLs
* @var object
*/
var $_url_format;
/**
* Reference to the parser used for parsing formulas
* @var object
*/
var $_parser;
/**
* Filehandle to the temporary file for storing data
* @var resource
*/
var $_filehandle;
/**
* Boolean indicating if we are using a temporary file for storing data
* @var bool
*/
var $_using_tmpfile;
/**
* Maximum number of rows for an Excel spreadsheet (BIFF5)
* @var integer
*/
var $_xls_rowmax;
/**
* Maximum number of columns for an Excel spreadsheet (BIFF5)
* @var integer
*/
var $_xls_colmax;
/**
* Maximum number of characters for a string (LABEL record in BIFF5)
* @var integer
*/
var $_xls_strmax;
/**
* First row for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_rowmin;
/**
* Last row for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_rowmax;
/**
* First column for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_colmin;
/**
* Last column for the DIMENSIONS record
* @var integer
* @see storeDimensions()
*/
var $_dim_colmax;
/**
* Array containing format information for columns
* @var array
*/
var $_colinfo;
/**
* Array containing the selected area for the worksheet
* @var array
*/
var $_selection;
/**
* Array containing the selected area for the worksheet
* @var array
*/
var $_selection;
/**
* Array containing the panes for the worksheet
* @var array
*/
var $_panes;
/**
* The active pane for the worksheet
* @var integer
*/
var $_active_pane;
/**
* Bit specifying if panes are frozen
* @var integer
*/
var $_frozen;
/**
* Bit specifying if the worksheet is selected
* @var integer
*/
var $selected;
/**
* The paper size (for printing) (DOCUMENT!!!)
* @var integer
*/
var $_paper_size;
/**
* Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait
* @var integer
*/
var $_orientation;
/**
* The page header caption
* @var string
*/
var $_header;
/**
* The page footer caption
* @var string
*/
var $_footer;
/**
* The horizontal centering value for the page
* @var integer
*/
var $_hcenter;
/**
* The vertical centering value for the page
* @var integer
*/
var $_vcenter;
/**
* The margin for the header
* @var float
*/
var $_margin_head;
/**
* The margin for the footer
* @var float
*/
var $_margin_foot;
/**
* The left margin for the worksheet in inches
* @var float
*/
var $_margin_left;
/**
* The right margin for the worksheet in inches
* @var float
*/
var $_margin_right;
/**
* The top margin for the worksheet in inches
* @var float
*/
var $_margin_top;
/**
* The bottom margin for the worksheet in inches
* @var float
*/
var $_margin_bottom;
/**
* First row to reapeat on each printed page
* @var integer
*/
var $title_rowmin;
/**
* Last row to reapeat on each printed page
* @var integer
*/
var $title_rowmax;
/**
* First column to reapeat on each printed page
* @var integer
*/
var $title_colmin;
/**
* First row of the area to print
* @var integer
*/
var $print_rowmin;
/**
* Last row to of the area to print
* @var integer
*/
var $print_rowmax;
/**
* First column of the area to print
* @var integer
*/
var $print_colmin;
/**
* Last column of the area to print
* @var integer
*/
var $print_colmax;
/** /**
* Constructor * Constructor
@ -60,7 +297,6 @@ class Worksheet extends BIFFwriter
$this->BIFFwriter(); // It needs to call its parent's constructor explicitly $this->BIFFwriter(); // It needs to call its parent's constructor explicitly
$rowmax = 65536; // 16384 in Excel 5 $rowmax = 65536; // 16384 in Excel 5
$colmax = 256; $colmax = 256;
$strmax = 255;
$this->name = $name; $this->name = $name;
$this->index = $index; $this->index = $index;
@ -69,19 +305,19 @@ class Worksheet extends BIFFwriter
$this->_url_format = &$url_format; $this->_url_format = &$url_format;
$this->_parser = &$parser; $this->_parser = &$parser;
$this->ext_sheets = array(); //$this->ext_sheets = array();
$this->_using_tmpfile = 1;
$this->_filehandle = ""; $this->_filehandle = "";
$this->fileclosed = 0; $this->_using_tmpfile = true;
$this->offset = 0; //$this->fileclosed = 0;
$this->xls_rowmax = $rowmax; //$this->offset = 0;
$this->xls_colmax = $colmax; $this->_xls_rowmax = $rowmax;
$this->xls_strmax = $strmax; $this->_xls_colmax = $colmax;
$this->dim_rowmin = $rowmax +1; $this->_xls_strmax = 255;
$this->dim_rowmax = 0; $this->_dim_rowmin = $rowmax + 1;
$this->dim_colmin = $colmax +1; $this->_dim_rowmax = 0;
$this->dim_colmax = 0; $this->_dim_colmin = $colmax + 1;
$this->colinfo = array(); $this->_dim_colmax = 0;
$this->_colinfo = array();
$this->_selection = array(0,0,0,0); $this->_selection = array(0,0,0,0);
$this->_panes = array(); $this->_panes = array();
$this->_active_pane = 3; $this->_active_pane = 3;
@ -101,14 +337,14 @@ class Worksheet extends BIFFwriter
$this->_margin_top = 1.00; $this->_margin_top = 1.00;
$this->_margin_bottom = 1.00; $this->_margin_bottom = 1.00;
$this->_title_rowmin = NULL; $this->title_rowmin = NULL;
$this->_title_rowmax = NULL; $this->title_rowmax = NULL;
$this->_title_colmin = NULL; $this->title_colmin = NULL;
$this->_title_colmax = NULL; $this->title_colmax = NULL;
$this->_print_rowmin = NULL; $this->print_rowmin = NULL;
$this->_print_rowmax = NULL; $this->print_rowmax = NULL;
$this->_print_colmin = NULL; $this->print_colmin = NULL;
$this->_print_colmax = NULL; $this->print_colmax = NULL;
$this->_print_gridlines = 1; $this->_print_gridlines = 1;
$this->_print_headers = 0; $this->_print_headers = 0;
@ -147,7 +383,7 @@ class Worksheet extends BIFFwriter
} }
else { else {
// If tmpfile() fails store data in memory // If tmpfile() fails store data in memory
$this->_using_tmpfile = 0; $this->_using_tmpfile = false;
} }
} }
@ -223,7 +459,8 @@ class Worksheet extends BIFFwriter
$this->_storePrintHeaders(); $this->_storePrintHeaders();
// Prepend EXTERNSHEET references // Prepend EXTERNSHEET references
for ($i = $num_sheets; $i > 0; $i--) { for ($i = $num_sheets; $i > 0; $i--)
{
$sheetname = $sheetnames[$i-1]; $sheetname = $sheetnames[$i-1];
$this->_storeExternsheet($sheetname); $this->_storeExternsheet($sheetname);
} }
@ -232,10 +469,10 @@ class Worksheet extends BIFFwriter
$this->_storeExterncount($num_sheets); $this->_storeExterncount($num_sheets);
// Prepend the COLINFO records if they exist // Prepend the COLINFO records if they exist
if (!empty($this->colinfo)){ if (!empty($this->_colinfo))
for($i=0; $i < count($this->colinfo); $i++)
{ {
$this->_storeColinfo($this->colinfo[$i]); for($i=0; $i < count($this->_colinfo); $i++) {
$this->_storeColinfo($this->_colinfo[$i]);
} }
$this->_storeDefcol(); $this->_storeDefcol();
} }
@ -250,8 +487,9 @@ class Worksheet extends BIFFwriter
// Append // Append
$this->_storeWindow2(); $this->_storeWindow2();
$this->_storeZoom(); $this->_storeZoom();
if(!empty($this->_panes)) if (!empty($this->_panes)) {
$this->_storePanes($this->_panes); $this->_storePanes($this->_panes);
}
$this->_storeSelection($this->_selection); $this->_storeSelection($this->_selection);
$this->_storeEof(); $this->_storeEof();
} }
@ -279,7 +517,8 @@ class Worksheet extends BIFFwriter
$buffer = 4096; $buffer = 4096;
// Return data stored in memory // Return data stored in memory
if (isset($this->_data)) { if (isset($this->_data))
{
$tmp = $this->_data; $tmp = $this->_data;
unset($this->_data); unset($this->_data);
$fh = $this->_filehandle; $fh = $this->_filehandle;
@ -289,7 +528,8 @@ class Worksheet extends BIFFwriter
return($tmp); return($tmp);
} }
// Return data stored on disk // Return data stored on disk
if ($this->_using_tmpfile) { if ($this->_using_tmpfile)
{
if ($tmp = fread($this->_filehandle, $buffer)) { if ($tmp = fread($this->_filehandle, $buffer)) {
return($tmp); return($tmp);
} }
@ -360,7 +600,7 @@ class Worksheet extends BIFFwriter
*/ */
function setColumn($firstcol, $lastcol, $width, $format = 0, $hidden = 0) function setColumn($firstcol, $lastcol, $width, $format = 0, $hidden = 0)
{ {
$this->colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden); $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden);
// Set width to zero if column is hidden // Set width to zero if column is hidden
$width = ($hidden) ? 0 : $width; $width = ($hidden) ? 0 : $width;
@ -599,12 +839,12 @@ class Worksheet extends BIFFwriter
*/ */
function repeatRows($first_row, $last_row = NULL) function repeatRows($first_row, $last_row = NULL)
{ {
$this->_title_rowmin = $first_row; $this->title_rowmin = $first_row;
if (isset($last_row)) { //Second row is optional if (isset($last_row)) { //Second row is optional
$this->_title_rowmax = $last_row; $this->title_rowmax = $last_row;
} }
else { else {
$this->_title_rowmax = $first_row; $this->title_rowmax = $first_row;
} }
} }
@ -618,12 +858,12 @@ class Worksheet extends BIFFwriter
*/ */
function repeatColumns($first_col, $last_col = NULL) function repeatColumns($first_col, $last_col = NULL)
{ {
$this->_title_colmin = $first_col; $this->title_colmin = $first_col;
if (isset($last_col)) { // Second col is optional if (isset($last_col)) { // Second col is optional
$this->_title_colmax = $last_col; $this->title_colmax = $last_col;
} }
else { else {
$this->_title_colmax = $first_col; $this->title_colmax = $first_col;
} }
} }
@ -639,10 +879,10 @@ class Worksheet extends BIFFwriter
*/ */
function printArea($first_row, $first_col, $last_row, $last_col) function printArea($first_row, $first_col, $last_row, $last_col)
{ {
$this->_print_rowmin = $first_row; $this->print_rowmin = $first_row;
$this->_print_colmin = $first_col; $this->print_colmin = $first_col;
$this->_print_rowmax = $last_row; $this->print_rowmax = $last_row;
$this->_print_colmax = $last_col; $this->print_colmax = $last_col;
} }
@ -815,12 +1055,10 @@ class Worksheet extends BIFFwriter
*/ */
function _XF(&$format) function _XF(&$format)
{ {
if($format != 0) if ($format != 0) {
{
return($format->getXfIndex()); return($format->getXfIndex());
} }
else else {
{
return(0x0F); return(0x0F);
} }
} }
@ -986,29 +1224,29 @@ class Worksheet extends BIFFwriter
$xf = $this->_XF($format); // The cell format $xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values // Check that row and col are valid and store max and min values
if ($row >= $this->xls_rowmax) if ($row >= $this->_xls_rowmax)
{ {
return(-2); return(-2);
} }
if ($col >= $this->xls_colmax) if ($col >= $this->_xls_colmax)
{ {
return(-2); return(-2);
} }
if ($row < $this->dim_rowmin) if ($row < $this->_dim_rowmin)
{ {
$this->dim_rowmin = $row; $this->_dim_rowmin = $row;
} }
if ($row > $this->dim_rowmax) if ($row > $this->_dim_rowmax)
{ {
$this->dim_rowmax = $row; $this->_dim_rowmax = $row;
} }
if ($col < $this->dim_colmin) if ($col < $this->_dim_colmin)
{ {
$this->dim_colmin = $col; $this->_dim_colmin = $col;
} }
if ($col > $this->dim_colmax) if ($col > $this->_dim_colmax)
{ {
$this->dim_colmax = $col; $this->_dim_colmax = $col;
} }
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
@ -1053,36 +1291,36 @@ class Worksheet extends BIFFwriter
$str_error = 0; $str_error = 0;
// Check that row and col are valid and store max and min values // Check that row and col are valid and store max and min values
if ($row >= $this->xls_rowmax) if ($row >= $this->_xls_rowmax)
{ {
return(-2); return(-2);
} }
if ($col >= $this->xls_colmax) if ($col >= $this->_xls_colmax)
{ {
return(-2); return(-2);
} }
if ($row < $this->dim_rowmin) if ($row < $this->_dim_rowmin)
{ {
$this->dim_rowmin = $row; $this->_dim_rowmin = $row;
} }
if ($row > $this->dim_rowmax) if ($row > $this->_dim_rowmax)
{ {
$this->dim_rowmax = $row; $this->_dim_rowmax = $row;
} }
if ($col < $this->dim_colmin) if ($col < $this->_dim_colmin)
{ {
$this->dim_colmin = $col; $this->_dim_colmin = $col;
} }
if ($col > $this->dim_colmax) if ($col > $this->_dim_colmax)
{ {
$this->dim_colmax = $col; $this->_dim_colmax = $col;
} }
if ($strlen > $this->xls_strmax) // LABEL must be < 255 chars if ($strlen > $this->_xls_strmax) // LABEL must be < 255 chars
{ {
$str = substr($str, 0, $this->xls_strmax); $str = substr($str, 0, $this->_xls_strmax);
$length = 0x0008 + $this->xls_strmax; $length = 0x0008 + $this->_xls_strmax;
$strlen = $this->xls_strmax; $strlen = $this->_xls_strmax;
$str_error = -3; $str_error = -3;
} }
@ -1109,29 +1347,29 @@ class Worksheet extends BIFFwriter
//$length = 0x0006 + $note_length; // Bytes to follow //$length = 0x0006 + $note_length; // Bytes to follow
// Check that row and col are valid and store max and min values // Check that row and col are valid and store max and min values
if ($row >= $this->xls_rowmax) if ($row >= $this->_xls_rowmax)
{ {
return(-2); return(-2);
} }
if ($col >= $this->xls_colmax) if ($col >= $this->_xls_colmax)
{ {
return(-2); return(-2);
} }
if ($row < $this->dim_rowmin) if ($row < $this->_dim_rowmin)
{ {
$this->dim_rowmin = $row; $this->_dim_rowmin = $row;
} }
if ($row > $this->dim_rowmax) if ($row > $this->_dim_rowmax)
{ {
$this->dim_rowmax = $row; $this->_dim_rowmax = $row;
} }
if ($col < $this->dim_colmin) if ($col < $this->_dim_colmin)
{ {
$this->dim_colmin = $col; $this->_dim_colmin = $col;
} }
if ($col > $this->dim_colmax) if ($col > $this->_dim_colmax)
{ {
$this->dim_colmax = $col; $this->_dim_colmax = $col;
} }
// Length for this record is no more than 2048 + 6 // Length for this record is no more than 2048 + 6
@ -1182,29 +1420,29 @@ class Worksheet extends BIFFwriter
$xf = $this->_XF($format); // The cell format $xf = $this->_XF($format); // The cell format
// Check that row and col are valid and store max and min values // Check that row and col are valid and store max and min values
if ($row >= $this->xls_rowmax) if ($row >= $this->_xls_rowmax)
{ {
return(-2); return(-2);
} }
if ($col >= $this->xls_colmax) if ($col >= $this->_xls_colmax)
{ {
return(-2); return(-2);
} }
if ($row < $this->dim_rowmin) if ($row < $this->_dim_rowmin)
{ {
$this->dim_rowmin = $row; $this->_dim_rowmin = $row;
} }
if ($row > $this->dim_rowmax) if ($row > $this->_dim_rowmax)
{ {
$this->dim_rowmax = $row; $this->_dim_rowmax = $row;
} }
if ($col < $this->dim_colmin) if ($col < $this->_dim_colmin)
{ {
$this->dim_colmin = $col; $this->_dim_colmin = $col;
} }
if ($col > $this->dim_colmax) if ($col > $this->_dim_colmax)
{ {
$this->dim_colmax = $col; $this->_dim_colmax = $col;
} }
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
@ -1243,29 +1481,29 @@ class Worksheet extends BIFFwriter
// Check that row and col are valid and store max and min values // Check that row and col are valid and store max and min values
if ($row >= $this->xls_rowmax) if ($row >= $this->_xls_rowmax)
{ {
return(-2); return(-2);
} }
if ($col >= $this->xls_colmax) if ($col >= $this->_xls_colmax)
{ {
return(-2); return(-2);
} }
if ($row < $this->dim_rowmin) if ($row < $this->_dim_rowmin)
{ {
$this->dim_rowmin = $row; $this->_dim_rowmin = $row;
} }
if ($row > $this->dim_rowmax) if ($row > $this->_dim_rowmax)
{ {
$this->dim_rowmax = $row; $this->_dim_rowmax = $row;
} }
if ($col < $this->dim_colmin) if ($col < $this->_dim_colmin)
{ {
$this->dim_colmin = $col; $this->_dim_colmin = $col;
} }
if ($col > $this->dim_colmax) if ($col > $this->_dim_colmax)
{ {
$this->dim_colmax = $col; $this->_dim_colmax = $col;
} }
// Strip the '=' or '@' sign at the beginning of the formula string // Strip the '=' or '@' sign at the beginning of the formula string
@ -1275,7 +1513,8 @@ class Worksheet extends BIFFwriter
elseif (preg_match("/^@/",$formula)) { elseif (preg_match("/^@/",$formula)) {
$formula = preg_replace("/(^@)/","",$formula); $formula = preg_replace("/(^@)/","",$formula);
} }
else { else
{
//die("Unrecognised character for formula"); //die("Unrecognised character for formula");
// Error handling // Error handling
$this->writeString($row, $col, 'Unrecognised character for formula'); $this->writeString($row, $col, 'Unrecognised character for formula');
@ -1284,13 +1523,15 @@ class Worksheet extends BIFFwriter
// Parse the formula using the parser in Parser.php // Parse the formula using the parser in Parser.php
$error = $this->_parser->parse($formula); $error = $this->_parser->parse($formula);
if($this->isError($error)) { if ($this->isError($error))
{
$this->writeString($row, $col, $error->getMessage()); $this->writeString($row, $col, $error->getMessage());
return; return;
} }
$formula = $this->_parser->toReversePolish(); $formula = $this->_parser->toReversePolish();
if($this->isError($formula)) { if ($this->isError($formula))
{
$this->writeString($row, $col, $formula->getMessage()); $this->writeString($row, $col, $formula->getMessage());
return; return;
} }
@ -1654,10 +1895,10 @@ class Worksheet extends BIFFwriter
{ {
$record = 0x0000; // Record identifier $record = 0x0000; // Record identifier
$length = 0x000A; // Number of bytes to follow $length = 0x000A; // Number of bytes to follow
$row_min = $this->dim_rowmin; // First row $row_min = $this->_dim_rowmin; // First row
$row_max = $this->dim_rowmax; // Last row plus 1 $row_max = $this->_dim_rowmax; // Last row plus 1
$col_min = $this->dim_colmin; // First column $col_min = $this->_dim_colmin; // First column
$col_max = $this->dim_colmax; // Last column plus 1 $col_max = $this->_dim_colmax; // Last column plus 1
$reserved = 0x0000; // Reserved by Excel $reserved = 0x0000; // Reserved by Excel
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
@ -1905,7 +2146,8 @@ class Worksheet extends BIFFwriter
$length = 0x000A; // Number of bytes to follow $length = 0x000A; // Number of bytes to follow
// Code specific to frozen or thawed panes. // Code specific to frozen or thawed panes.
if ($this->_frozen) { if ($this->_frozen)
{
// Set default values for $rwTop and $colLeft // Set default values for $rwTop and $colLeft
if (!isset($rwTop)) { if (!isset($rwTop)) {
$rwTop = $y; $rwTop = $y;
@ -1914,7 +2156,8 @@ class Worksheet extends BIFFwriter
$colLeft = $x; $colLeft = $x;
} }
} }
else { else
{
// Set default values for $rwTop and $colLeft // Set default values for $rwTop and $colLeft
if (!isset($rwTop)) { if (!isset($rwTop)) {
$rwTop = 0; $rwTop = 0;
@ -2392,7 +2635,8 @@ class Worksheet extends BIFFwriter
function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1)
{ {
$bitmap_array = $this->_processBitmap($bitmap); $bitmap_array = $this->_processBitmap($bitmap);
if($this->isError($bitmap_array)) { if ($this->isError($bitmap_array))
{
$this->writeString($row, $col, $bitmap_array->getMessage()); $this->writeString($row, $col, $bitmap_array->getMessage());
return; return;
} }