phpLens
 home  products examples manual  faq support forum  contact news  login store

More Examples:   View Source:   Reporting Demo with Export to Excel

Free Download

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.

  Product Report for Jul-24-2014
E Nxt End Excel Srch
(E) (e)ProductName (e)QuantityPerUnit (e)UnitPrice (e)Units (e)Units (e)Order Level
  (e)Supplier: Exotic Liquids
1Producto, super12 - 550 ml bottles
10.12
13
70
25
2LEO10 boxes x 20 bags
18.00
39
0
10
 Average:
14.06
26.00
35.00
 
  (e)Supplier: New Orleans Cajun Delights
3Louisiana Hot Spiced Okra24 - 8 oz jars
17.00
4
100
20
4Louisiana Fiery Hot Pepper Sauce32 - 8 oz bottles
21.05
76
0
0
5Chef Anton's Gumbo Mix36 boxes
21.35
0
0
0
6Chef Anton's Cajun Seasoning48 - 6 oz jars
22.00
53
0
0
 Average:
20.35
33.25
25.00
 
  (e)Supplier: Grandma Kelly's Homestead
7Changie24 - 12 oz bottles
0.00
17
40
25
8Grandma's Boysenberry Spread12 - 8 oz jars
25.00
150
0
25
9Uncle Bob's Organic Dried Pears12 - 1 lb pkgs.
30.00
15
0
10
10Northwoods Cranberry Sauce12 - 12 oz jars
40.00
6
0
0
 Average:
23.75
47.00
10.00
 
  (e)Supplier: Tokyo Traders
11Longlife Tofu5 kg pkg.
10.00
4
20
5
12Ikuraa12 - 200 ml jars
31.00
31
0
0
13Mishi Kobe Niku18 - 500 g pkgs.
97.00
29
0
0
 Average:
46.00
21.33
6.67
 
  (e)Supplier: Cooperativa de Quesos 'Las Cabras'
14Queso Cabrales1 kg pkg.
21.00
25
35
35
15Queso Manchego La Pastora10 - 500 g pkgs.
38.00
86
0
0
 Average:
29.50
55.50
17.50
 
  (e)Supplier: Mayumi's
16Konbu2 kg box
6.00
24
0
5
17Genen Shouyu24 - 250 ml bottles
15.50
39
0
5
18Tofu40 - 100 g pkgs.
23.25
35
0
0
 Average:
14.92
32.67
0.00
 
  (e)Supplier: Pavlova, Ltd.
19Outback Lager24 - 355 ml bottles
15.00
15
10
30
20Pavlova32 - 500 g boxes
17.45
29
0
10
 Average:
16.23
22.00
5.00
 
 Average:
23.94
34.50
13.75
 

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.

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800