Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.2

Bug #9564 Worksheet::setColumn() can only be called once per range
Submitted: 2006-12-06 15:02 UTC Modified: 2009-11-29 03:02 UTC
From: dan at spiderweblabs dot com Assigned: cschmitz
Status: Closed Package: Spreadsheet_Excel_Writer (version 0.9.1)
PHP Version: 5.1.6 OS: Windows Server 2003
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dan at spiderweblabs dot com
New email:
PHP Version: Package Version: OS:

 

 [2006-12-06 15:02 UTC] dan at spiderweblabs dot com (Dan Lynn)
Description: ------------ I plan on fixing this and submitting back to CVS, but I thought I'd let everyone know ahead of time. Worksheet::setColumn() adds a new array onto the Worksheet::_colinfo array. I think the desired behavior would be to override previous overlapping entries, splitting ranges where necessary. Test script: --------------- $workbook = new Spreadsheet_Excel_Writer(); $worksheet =& $workbook->addWorksheet(); $worksheet->setColumn(0,0,10); $worksheet->setColumn(0,0,100); $workbook->send("text.xls"); $workbook->close(); Expected result: ---------------- I expect column A to be 100 units wide; Actual result: -------------- Column A is 10 units wide;

Comments

 [2006-12-06 16:56 UTC] dan at spiderweblabs dot com
Here is my modified Worksheet::setColumn() method: /** * Set the width of a single column or a range of columns. * * @access public * @param integer $firstcol first column on the range * @param integer $lastcol last column on the range * @param integer $width width to set * @param mixed $format The optional XF format to apply to the columns * @param integer $hidden The optional hidden atribute * @param integer $level The optional outline level */ function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) { // added by Dan Lynn <dan@spiderweblabs.com) on 2006-12-06 // look for any ranges this might overlap and remove, size or split where necessary foreach ($this->_colinfo as $key => $colinfo) { $existing_start = $colinfo[0]; $existing_end = $colinfo[1]; // if the new range starts within another range if ($firstcol > $existing_start && $firstcol < $existing_end) { // trim the existing range to the beginning of the new range $this->_colinfo[$key][1] = $firstcol - 1; // if the new range lies WITHIN the existing range if ($lastcol < $existing_end) { // split the existing range by adding a range after our new range $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], &$colinfo[3], $colinfo[4], $colinfo[5]); } } // if the new range ends inside an existing range elseif ($lastcol > $existing_start && $lastcol < $existing_end) { // trim the existing range to the end of the new range $this->_colinfo[$key][0] = $lastcol + 1; } // if the new range completely overlaps the existing range elseif ($firstcol <= $existing_start && $lastcol >= $existing_end) { unset($this->_colinfo[$key]); } } // added by Dan Lynn <dan@spiderweblabs.com) on 2006-12-06 // regenerate keys $this->_colinfo = array_values($this->_colinfo); $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; } }
 [2009-11-29 03:02 UTC] cschmitz (Carsten Schmitz)
-Status: Open +Status: Closed -Assigned To: +Assigned To: cschmitz
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Thank you very much for this great patch!