Styling best practices

Topics: User Forum
Mar 19, 2009 at 6:48 PM
Is it more efficient (or even possible) to set text wrapping using a shared style, or is it fine if I set text wrapping individually on each cell.  Is it going to require more memory if I don't use a shared style for text wrapping?
Mar 19, 2009 at 8:07 PM
You can use shared styles like in example 23sharedstyles.php in the Tests folder. This way of styling the Excel workbook is available to those who need to keep memory usage at a minimum. This is not mentioned in the developer documentation because it will not work as expected if you load a workbook and try to modify the styles. But those who are familiar with PEAR Spreadsheet_Excel_Writer will find this technique familiar.

Using shared styles, you may not see any significant increase in speed using PHPExcel 1.6.6. However, with latest source code

you may see improvements thanks to recent implementation of hash codes caching (I haven't tested yet)

Please note, we are working on fixing the way styling works in PHPExcel, and recommendation may change with respect to usage of shared styles.

Mar 19, 2009 at 8:11 PM
Thanks for the response.  Is text wrapping one of the properties included in a shared style object?  I haven't seen an example that uses text wrapping inside a shared style.
Mar 19, 2009 at 8:42 PM
All the usual style properties are available including text wrap. There is no difference between the shared style object and the usual (unshared) shared style object.