From 221d004e8fb31a0f644b825dbe297a0a4abf35bd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 8 Sep 2007 17:39:18 +0000 Subject: [PATCH] Fix: debugage --- htdocs/exports/export.php | 4 +- .../class.writeexcel_formula.inc.php | 1 + .../class.writeexcel_workbook.inc.php | 4 +- .../class.writeexcel_worksheet.inc.php | 72 +++++++++++++++---- .../php_writeexcel/example-colors.php | 9 ++- .../includes/php_writeexcel/example-demo.php | 22 +++--- .../includes/phpexcelreader/excelreader.php | 8 ++- 7 files changed, 88 insertions(+), 32 deletions(-) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index e6fa4828a52..eefc8c7ce39 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -620,11 +620,11 @@ if ($step == 4 && $datatoexport) print ''; // test d'affichage du tableau excel - + /* print '
'; viewExcelFileContent($conf->export->dir_temp.'/1/export_commande_1.xls'); print '
'; - + */ } diff --git a/htdocs/includes/php_writeexcel/class.writeexcel_formula.inc.php b/htdocs/includes/php_writeexcel/class.writeexcel_formula.inc.php index 58c6ff87eab..ce3dc1d8aa4 100644 --- a/htdocs/includes/php_writeexcel/class.writeexcel_formula.inc.php +++ b/htdocs/includes/php_writeexcel/class.writeexcel_formula.inc.php @@ -1456,6 +1456,7 @@ function _func() { $num_args = 0; // number of arguments received $function = $this->_current_token; + $result=0; $this->_advance(); $this->_advance(); // eat the "(" while ($this->_current_token != ')') diff --git a/htdocs/includes/php_writeexcel/class.writeexcel_workbook.inc.php b/htdocs/includes/php_writeexcel/class.writeexcel_workbook.inc.php index 8ca73cd0d7c..184c76116f6 100644 --- a/htdocs/includes/php_writeexcel/class.writeexcel_workbook.inc.php +++ b/htdocs/includes/php_writeexcel/class.writeexcel_workbook.inc.php @@ -663,7 +663,7 @@ function _store_all_xfs() { # The default font index is 0 # $format = $this->_tmp_format; - $xf; + $xf=NULL; for ($c=0;$c<15;$c++) { $xf = $format->get_xf('style'); # Style XF @@ -1114,7 +1114,7 @@ function _store_palette() { $record = 0x0092; # Record identifier $length = 2 + 4 * sizeof($aref); # Number of bytes to follow $ccv = sizeof($aref); # Number of RGB values to follow - //$data; # The RGB data + $data=NULL; # The RGB data # Pack the RGB data foreach($aref as $dat) { diff --git a/htdocs/includes/php_writeexcel/class.writeexcel_worksheet.inc.php b/htdocs/includes/php_writeexcel/class.writeexcel_worksheet.inc.php index 9860cbf7e63..9c8ffe1d0ee 100644 --- a/htdocs/includes/php_writeexcel/class.writeexcel_worksheet.inc.php +++ b/htdocs/includes/php_writeexcel/class.writeexcel_worksheet.inc.php @@ -432,8 +432,16 @@ function set_column() { return; } - $width = $_[4] ? 0 : $_[2]; # Set width to zero if column is hidden - $format = $_[3]; + if (isset($_[4])) { + $width = $_[4]; + } else { + $width = 0 ; # Set width to zero if column is hidden + } + if (isset($_[3])) { + $format = $_[3]; + } else { + $format = NULL; + } list($firstcol, $lastcol) = $_; @@ -1149,8 +1157,12 @@ function write_number() { $col = $_[1]; # Zero indexed column $num = $_[2]; //!!! - $xf = $this->_XF($row, $col, $_[3]); # The cell format - + if (isset($_[3])) { + $xf = $this->_XF($row, $col, $_[3]); # The cell format + } else { + $xf = $this->_XF($row, $col, NULL); # 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; } @@ -1206,7 +1218,11 @@ function write_string() { $col = $_[1]; # Zero indexed column $strlen = strlen($_[2]); $str = $_[2]; - $xf = $this->_XF($row, $col, $_[3]); # The cell format + if (isset($_[3])) { + $xf = $this->_XF($row, $col, $_[3]); # The cell format + } else { + $xf = $this->_XF($row, $col, NULL); # The cell format + } $str_error = 0; @@ -1331,7 +1347,11 @@ function write_formula() { # 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($row, $col, $_[3]); # The cell format + if (isset($_[3])) { + $xf = $this->_XF($row, $col, $_[3]); # The cell format + } else { + $xf = $this->_XF($row, $col, NULL); # The cell format + } $num = 0x00; # Current value of formula $grbit = 0x03; # Option flags $chn = 0x0000; # Must be zero @@ -1467,7 +1487,11 @@ function _write_url_web() { if (isset($_[5])) { $str = $_[5]; # Alternative label } - $xf = $_[6] ? $_[6] : $this->_url_format; # The cell format + if (isset($_[6])) { + $xf = $_[6] ; # The cell format + } else { + $xf = $this->_url_format; # The cell format + } # Write the visible label using the write_string() method. if(!isset($str)) { @@ -1971,10 +1995,17 @@ function _store_colinfo($_) { $coldx += 0.72; # Fudge. Excel subtracts 0.72 !? $coldx *= 256; # Convert to units of 1/256 of a char - //$ixfe; # XF index - $grbit = $_[4] || 0; # Option flags + $ixfe=NULL; # XF index + $grbit = 0; + if (isset($_[4])) { + $grbit = $_[4] ; # Option flags + } $reserved = 0x00; # Reserved - $format = $_[3]; # Format object + + $format = 0x0F; + if (isset($_[3])) { + $format = $_[3]; # Format object + } # Check for a format object if (isset($_[3])) { @@ -2008,8 +2039,15 @@ function _store_selection($_) { $rwFirst = $_[0]; # First row in reference $colFirst = $_[1]; # First col in reference - $rwLast = $_[2] ? $_[2] : $rwFirst; # Last row in reference - $colLast = $_[3] ? $_[3] : $colFirst; # Last col in reference + $rwLast = $rwFirst; # Last row in reference + if (isset($_[2])) { + $rwLast = $_[2]; # Last row in reference + } + + $colLast = $colFirst; # Last col in reference + if (isset($_[3])) { + $colLast = $_[3] ; # Last col in reference + } # Swap last row/col for first row/col as necessary if ($rwFirst > $rwLast) { @@ -2595,8 +2633,14 @@ function insert_bitmap() { $bitmap = $_[2]; $x = $_[3] ? $_[3] : 0; $y = $_[4] ? $_[4] : 0; - $scale_x = $_[5] ? $_[5] : 1; - $scale_y = $_[6] ? $_[6] : 1; + $scale_x = 1; + $scale_y = 1; + if (isset($_[5])) { + $scale_x = $_[5] ; + } + if (isset($_[6])) { + $scale_y = $_[6] ; + } list($width, $height, $size, $data) = $this->_process_bitmap($bitmap); diff --git a/htdocs/includes/php_writeexcel/example-colors.php b/htdocs/includes/php_writeexcel/example-colors.php index 2705a7e6a67..6868b0db2a6 100644 --- a/htdocs/includes/php_writeexcel/example-colors.php +++ b/htdocs/includes/php_writeexcel/example-colors.php @@ -13,10 +13,11 @@ require_once "class.writeexcel_workbook.inc.php"; require_once "class.writeexcel_worksheet.inc.php"; $fname = tempnam("/tmp", "colors.xls"); -$workbook = &new writeexcel_workbook($fname); +$workbook = new writeexcel_workbook($fname); # Some common formats $center =& $workbook->addformat(array('align' => 'center')); + $heading =& $workbook->addformat(array('align' => 'center', 'bold' => 1)); # Try this to see the default Excel 5 palette @@ -47,6 +48,7 @@ $colors = array( $worksheet1 =& $workbook->addworksheet('Named colors'); + $worksheet1->set_column(0, 3, 15); $worksheet1->write(0, 0, "Index", $heading); @@ -71,6 +73,10 @@ foreach ($colors as $color=>$index) { } + + + + ###################################################################### # # Demonstrate the standard Excel colors in the range 8..63. @@ -104,6 +110,7 @@ for ($i=8;$i<=63;$i++) { } } + $workbook->close(); header("Content-Type: application/x-msexcel; name=\"example-colors.xls\""); diff --git a/htdocs/includes/php_writeexcel/example-demo.php b/htdocs/includes/php_writeexcel/example-demo.php index 147bdcb2bb8..f06c6a128ed 100644 --- a/htdocs/includes/php_writeexcel/example-demo.php +++ b/htdocs/includes/php_writeexcel/example-demo.php @@ -17,10 +17,10 @@ $worksheet3 =& $workbook->addworksheet('And another'); # $worksheet->set_column('A:B', 32); $heading =& $workbook->addformat(array( - bold => 1, - color => 'blue', - size => 18, - merge => 1, + 'bold' => 1, + 'color' => 'blue', + 'size' => 18, + 'merge' => 1, )); $headings = array('Features of php_writeexcel', ''); @@ -31,11 +31,11 @@ $worksheet->write_row('A1', $headings, $heading); # Some text examples # $text_format =& $workbook->addformat(array( - bold => 1, - italic => 1, - color => 'red', - size => 18, - font => 'Comic Sans MS' + 'bold' => 1, + 'italic' => 1, + 'color' => 'red', + 'size' => 18, + 'font' => 'Comic Sans MS' )); $worksheet->write('A2', "Text"); @@ -47,8 +47,8 @@ $worksheet->write('B3', "Hello Excel", $text_format); # # Some numeric examples # -$num1_format =& $workbook->addformat(array(num_format => '$#,##0.00')); -$num2_format =& $workbook->addformat(array(num_format => ' d mmmm yyy')); +$num1_format =& $workbook->addformat(array('num_format' => '$#,##0.00')); +$num2_format =& $workbook->addformat(array('num_format' => ' d mmmm yyy')); $worksheet->write('A4', "Numbers"); $worksheet->write('B4', 1234.56); diff --git a/htdocs/includes/phpexcelreader/excelreader.php b/htdocs/includes/phpexcelreader/excelreader.php index 9d799c44050..4be489a029e 100644 --- a/htdocs/includes/phpexcelreader/excelreader.php +++ b/htdocs/includes/phpexcelreader/excelreader.php @@ -725,22 +725,24 @@ class Spreadsheet_Excel_Reader $spos += $length + 4; //var_dump($this->formatRecords); //echo "code $code $length"; + //echo 'code dimension '.base_convert(SPREADSHEET_EXCEL_READER_TYPE_DIMENSION,10,16).'
'; while($cont) { //echo "mem= ".memory_get_usage()."\n"; // $r = &$this->file->nextRecord(); $lowcode = ord($this->data[$spos]); + //echo 'lowcode '.$lowcode.'
'; if ($lowcode == SPREADSHEET_EXCEL_READER_TYPE_EOF) break; $code = $lowcode | ord($this->data[$spos+1])<<8; $length = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8; $spos += 4; $this->sheets[$this->sn]['maxrow'] = $this->_rowoffset - 1; $this->sheets[$this->sn]['maxcol'] = $this->_coloffset - 1; - //echo "Code=".base_convert($code,10,16)." $code\n"; + //echo "Code=".base_convert($code,10,16)." - base16=".$code."
"; unset($this->rectype); $this->multiplier = 1; // need for format with % switch ($code) { case SPREADSHEET_EXCEL_READER_TYPE_DIMENSION: - //echo 'Type_DIMENSION '; + //echo 'Type_DIMENSION
'; if (!isset($this->numRows)) { if (($length == 10) || ($version == SPREADSHEET_EXCEL_READER_BIFF7)){ $this->sheets[$this->sn]['numRows'] = ord($this->data[$spos+2]) | ord($this->data[$spos+3]) << 8; @@ -751,6 +753,8 @@ class Spreadsheet_Excel_Reader } } //echo 'numRows '.$this->numRows.' '.$this->numCols."\n"; + //echo 'numRows '.$this->sheets[$this->sn]['numRows'].'
'; + //echo 'numRows '.$this->sheets[$this->sn]['numCols'].'
'; break; case SPREADSHEET_EXCEL_READER_TYPE_MERGEDCELLS: $cellRanges = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;