Re: Structures_DataGrid_Renderer_XLS: I just get empty files
| From: | Markus Ernst | Date: | Wed, 28 Feb 2007 12:00:18 +0000 |
| Subject: | Re: Structures_DataGrid_Renderer_XLS: I just get empty files | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26688@lists.php.net to get a copy of this message | ||
(Michael Mauch) schrieb:
Markus Ernst wrote:http://pear.php.net/bugs/bug.php?id=1572Now with my real world data I still have the *** ERROR IN SST *** problem that is already described in a bug for Spreadsheet_Excel_Writer, but that should (according to a comment in the bug report) be solved in the actual version when setting setVersion(8). Anyway the problem seems to persist.Do you have an URL for that bug?
Could you write a complete example so we can try it? 5 columns and 89 lines seems to be still tiny.<?php // Initiate datagrid ini_set('include_path', $_SERVER['DOCUMENT_ROOT'].'/tools/PEAR'.':'.ini_get('include_path')); require_once 'Structures/DataGrid.php'; $datagrid =& new Structures_DataGrid(); // Create data with 200 records, 5 columns, unique strings $data = array(); for ($i=0; $i<200; $i++) { $data[] = array($i.'hello there', $i.'this', $i.'is', $i.'a', $i.'test'); } $datagrid->bind($data); // Set columns $datagrid->addColumn(new Structures_DataGrid_Column('Column 1', 0)); $datagrid->addColumn(new Structures_DataGrid_Column('Column 2', 1)); $datagrid->addColumn(new Structures_DataGrid_Column('Column 3', 2)); $datagrid->addColumn(new Structures_DataGrid_Column('Column 4', 3)); $datagrid->addColumn(new Structures_DataGrid_Column('Column 5', 4)); // Attach XLS renderer $options = array( 'filename' => 'errorInSSTTest.xls', 'encoding' => 'utf-8' ); $renderer =& $datagrid->setRenderer(DATAGRID_RENDER_XLS, $options); // Get the workbook object and set the temp directory and version // Of course temp directory must be created manually and chmoded // with writing permission for PHP $workbook =& $renderer->getContainer(); $workbook->setTempDir($_SERVER['DOCUMENT_ROOT'].'/temp/'); $workbook->setVersion(8); // Output file $datagrid->render($renderer); exit; ?> When opening the resulting file, - Excel shows a broken file warning and displays until row 105, Col 2 - OpenOffice starts displaying distorted characters at the same column, and *** ERROR IN SST *** a few rows later. Some more facts: - It happens with utf-8 encoding, but not with default encoding (iso-8859-1). - As the example shows, it also happens if no special characters are in the data. - There seems to be a relationship between the total amount of text in unique field contents: If you change the second column contents from $i.'this' to 'this', the error starts in row 127; now change the third column contents from $i.'is' to $i.'iss', then the error starts in row 123. Do you think I should file a bug with this info? If yes, does it belong to Structures_DataGrid_Renderer_XLS or rather to Spreadsheet_Excel_Writer?