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

Bug #1239 function mergeCells does not support merged text
Submitted: 2004-04-19 10:04 UTC
From: place2be at gmx dot de Assigned:
Status: Bogus Package: Spreadsheet_Excel_Writer
PHP Version: 4.3.4 OS: WinXP
Roadmaps: (Not assigned)    

 [2004-04-19 10:04 UTC] place2be at gmx dot de
Description: ------------ If I use the function mergeCells, I can´t put some merged text into these cells. The text stands in the first cell and is cut at the right edge. Also tried to use setAlign('merge') as and addFormat() function for the text. But in this case, the text is cut at the left and right corner of the first cell. Tried to view the result file with Excel 2003. System: Used Spreadsheet_Excel_Writer v0.7 with OLE 0.5. WinXP Professional SP1 PHP 4.3.4 Apache 1.3.29 Reproduce code: --------------- <?php require_once 'Spreadsheet/Excel/Writer.php'; $workbook = new Spreadsheet_Excel_Writer ('c:\export.xls'); $worksheet =& $workbook->addWorksheet('test'); $worksheet->mergeCells(0,0,0,4); $worksheet->write(0,0, "merge over predefined number of cells"); $workbook->close(); ?> Expected result: ---------------- I expect, that the text "merge over predefined number of cells" is merged between the Cells from row 0, column 0 to row 0, column 4. Actual result: -------------- The text is shown in row 0, column 0, and it is cut at the right edge of the cell (If the cell is not as wide as the text, of course).


 [2004-04-19 22:56 UTC] xnoguer at php dot net
Thank you for taking the time to write to us, but this is not a bug. mergeCells() is an experimental method only available for Excel 97/2000. If you want to use it, try: $workbook->setVersion(8);
 [2004-04-20 04:32 UTC] place2be at gmx dot de
You´re right, it is no bug. I found the problem, and it works now. Just was a little bit frustrated, because there were no detailed informations about mergeCells() in the documentation. You have to write the text to the sheet first(and with format 'center', not merge), then merge the cells. This way, it works for me with Excel 2003: <?php require_once 'Spreadsheet/Excel/Writer.php'; $workbook = new Spreadsheet_Excel_Writer ('c:\export.xls'); $worksheet =& $workbook->addWorksheet('test'); $format_center =& $workbook->addFormat(); $format_center->setAlign('center'); $worksheet->write(0,0, "merge over predefined number of cells",$format_center); $worksheet->mergeCells(0,0,0,4); $workbook->close(); ?> Perhaps, you could add this to your documentation. :) Thanks for your answer and the great work you´ve done with this package ! greets, Chris.