Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
You can build tables growing horizontally rather than vertically by using table-column data bands.
A table-column data band represents a data band, which body occupies a rectangular area of cells of a single document table. The body of such a band starts at the beginning of the top-left cell of a corresponding area and ends at the end of its bottom-right cell. Typically, this area consists of one or several table columns as follows.
| ... | <<foreach ... -horz>> ... | ... | ... | ... |
| ... | ... | ... | ... | ... |
| ... | ... | ... | ... <</foreach>> | ... |
Note – The horz switch instructs the engine to affect table columns rather than rows.
However, unlike table-row data bands able to capture only whole rows, table-column data bands can occupy columns even partially as shown in the following template snippet.
| ... | ... | ... | ... | ... |
| ... | <<foreach ... -horz>> ... | ... | ... | ... |
| ... | ... | ... | ... | ... |
| ... | ... | ... | ... <</foreach>> | ... |
| ... | ... | ... | ... | ... |
Let us consider typical use cases for table-column data bands at first defining ds, a DataSet instance containing DataTable and DataRelation objects according to the following data model.
The most common scenario for a table-column data band is building of a document table that represents a list of items side by side. You can use a template like the following one to achieve this.
| Good | <<foreach [s in ds.Sales] -horz>><<[s.Goods.Name]>> | Total: |
| Pack | <<[s.Packs.Name]>> | |
| Sold Quantity | <<[s.Quantity]>><</foreach>> | <<[ds.Sales.sum(s => s.Quantity)]>> |
In this case, the engine produces a report as follows.
| Good | Drinking Water | Drinking Water | Mineral Water | Mineral Water | Total: |
|---|---|---|---|---|---|
| Pack | 1.5 L | 500 ml | 1.5 L | 500 ml | |
| Sold Quantity | 12 | 27 | 5 | 13 | 57 |
To grow a document table horizontally by filling it with master-detail data, you can use nested table-column data bands like in the following template.
| Good | <<foreach [g in ds.Goods] -horz>><<[g.Name]>> | <<foreach [s in g.Sales]>><<[s.Packs.Name]>> | Total: |
| Sold Packs | <<[g.Sales.sum(s => s.Quantity)]>> | <<[s.Quantity]>><</foreach>><</foreach>> | <<[ds.Sales.sum(s => s.Quantity)]>> |
In this case, the engine produces a report as follows.
| Good / Pack | Drinking Water | 1.5 L | 500 ml | Mineral Water | 1.5 L | 500 ml | Total: |
|---|---|---|---|---|---|---|---|
| Sold Quantity | 39 | 12 | 27 | 18 | 5 | 13 | 57 |
You can normally use common data bands nested to table-column data bands as well like in the following template.
| Good | <<foreach [g in ds.Goods] -horz>><<[g.Name]>> |
| Sold Packs | <<foreach [s in g.Sales]>><<[s.Packs.Name]>> <</foreach>><</foreach>> |
In this case, the engine produces a report as follows.
| Good | Drinking Water | Mineral Water |
|---|---|---|
| Sold Packs | 1.5 L 500 ml | 1.5 L 500 ml |
Note – Table‑column data bands can themselves be nested to table‑row data bands (see “Working with Cross (Pivot) Tables” for details), but not conversely: Nesting of table‑row data bands into table‑column data bands is forbidden.
For more examples of templates for typical scenarios involving table‑column data bands, see “Appendix C. Typical Templates”.
Q: How do I enable the horizontal (column‑wise) mode for a foreach tag?
A: Add the -horz switch to the foreach tag, e.g. <<foreach [item in ds.Items] -horz>>. This tells the LINQ Reporting Engine to repeat the band across table columns instead of rows.
Q: Can I nest table‑column data bands inside each other?
A: Yes. You can place a foreach with -horz inside another foreach with -horz. The inner band will repeat for each column generated by the outer band, allowing multi‑level horizontal layouts.
Q: Is it possible to mix table‑column and table‑row data bands in the same table?
A: You can nest a table‑row data band inside a table‑column data band, but you cannot place a table‑column band inside a row band. Use a row band for vertical repetition and a column band for horizontal repetition as needed.
Q: How do I calculate a sum of a numeric field inside a table‑column data band?
A: Use the LINQ sum extension inside a tag, for example <<[ds.Sales.sum(s => s.Quantity)]>>. The expression is evaluated against the data source and the result is inserted into the document.
Q: I get “Tag end is unexpected” when closing a nested foreach with -horz. What is wrong?
A: Ensure that each opening tag has a matching closing tag and that the closing tag does not contain extra characters. For a nested column band, the correct syntax is <<foreach [s in ds.Sales] -horz>> … << /foreach>>. Remove any stray > or missing spaces between << and /foreach>>.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.