Click on the Excel icon on the top right of the report to export in CSV format.
This demo also shows multi-level titles, grouping by Supplier, and unit averages.
Notes
This demo shows how to produce a complex report.
We use the groupLens property to group records by supplier, and lookupLens property to map the supplier id to
the actual supplier company name.
We use the avgLens property to calculate averages for the above columns, and set the
appropriate captions by modifying the txtTotal and txtSubTotal properties. We
use the topCaption property to set it to "Product Report".
Export to Excel
We also support exporting to Excel since phpLens 2.2. We can export both in Excel 5 binary format
or CSV. This requires a directory to be defined with the imageTmpDir property to store
the temporary CSV or Excel format file.
The columns to be exported are defined by the exportLens property.
Note the ob_start() at the beginning of the code (click View Source). This allows us to
perform a HTTP redirect, so the export file will automatically download.
TitleLevels and ColorLevels
We use the titleLevel1, titleLevel2 and titleColor properties to display more complex
report headers. For example:
$lens->titleLevel2 = 'ProductName^3^^palegoldenrod;UnitsInStock^1^{NBSP} In Stock {NBSP}^peachpuff;UnitsOnOrder^2^On Order^bisque';
This means, starting from ProductName, create a column that spans 3 cols, followed by a column
starting from UnitsInStock called "In Stock" colored peachpuff, and lastly a column starting from
UnitsOnOrder spanning 2 cols, named Ordering with the color bisque. {NBSP} will be replaced with
(non-breaking space).
If you require an additional row of title headers, you can also define this row with the titleLevel3 property.