| Search Locate Previous | Contents |
Version 1.5 of NewLeaf adds the capability to take data which is much too wide to fit on the page, and split the table both horizontally and vertically on to as many pages as necessary. To set up some suitable test data ...
wks('Wk'),¨¨¼52 sku'P',¨¨¼8 sales?((½sku),(½wks))½1000
We can start with some very simple code to set up the column widths and run the report:
leaf.Use'' leaf.table.Titles('Product'),wks leaf.table.CellWidths 72,(½wks)½60 leaf.table.Align('Cen'),(½wks)½'Right' leaf.table.List sku,sales PostScrp.View leaf.Close
You can see that NewLeaf has fitted three folds of the short table into the available space, but it would clearly be better to repeat the product id at the left-hand side of each repeat.
The new property which you will use to control this is called KeyStyle, and can be used to force repeating columns, blank out repeated rows, rule when a key changes, and so on.
In this case, we can set the first column to repeat on every fold of the report:
leaf.Use'' leaf.table.Titles('Product'),wks leaf.table.CellWidths 72,(½wks)½60 leaf.table.Align('Cen'),(½wks)½'Right' leaf.table.KeyStyle 1,(½wks)½0 leaf.table.List sku,sales PostScrp.View leaf.Close
Now we have a much better structured table it would be interesting to extend it by adding a product category column to the left, and having the horizontal rules shown only when the category changes.
The next example adds more products, and groups them into 4 categories. The normal gridlines are suppressed, and the KeyStyle is set to 11 (1+2+8) which forces the column to repeat (1) and also blanks repeated rows (2) and rules across the grid when ever the value of this column changes (8).
wks('Wk'),¨¨¼52
sku'P',¨¨¼11
type3 2 4 2/'One' 'Two' 'Three' 'Four'
sales?((½sku),(½wks))½1000
leaf.Use''
leaf.table.Titles('Product'),wks
leaf.table.CellWidths 72 72,(½wks)½60
leaf.table.Align('Left' 'Cen'),(½wks)½'Right'
leaf.table.Gridlines 1 0.2 0
leaf.table.KeyStyle 11 1,(½wks)½0
leaf.table.List type,sku,sales
PostScrp.View leaf.Close
You might like to continue to experiment with more held columns, shading, forced column breaks and so on. There is an example function Folder in the NewLeaf workspace which shows most of the possibilities.