Reputation: 1799
I want to define an Excel template to be used with JXLS (current version 2.2.5) in such a way that there is a dynamic grid (i.e. I do not know the number of columns before-hand), and to the right side of it, another grid:
Header 1.1 | Header 1.2 | | Header 2.1 | Header 2.2 | Header 2.3
------------------------- --------------------------------------
A B C D E
F G H I J
The two grids have the same number of rows, but I'd prefer to not merge them because they have separate styles.
Is it possible, and if yes: how?
I tried the GridCommandDemo from the jxls-demo collection and put some static text (to start with) into a cell right of the area with the grid, but it was simply overwritten. I had expected it to be moved to the right.
Upvotes: 2
Views: 2735
Reputation: 11
Reviving this 5 year-old thread just to add my own input - since the accepted answer (or the answer to it) doesn't really tell the whole story.
I ended up using one area for (in my case) both grids:
jx:area(lastCell="B7")
The cell B7 is the last cell of my second grid. First grid:
jx:grid(lastCell="B4" headers="firstGridHeaders" data="firstGridData" areas=[B3:B3, B4:B4])
Second grid:
jx:grid(lastCell="B7" headers="secondGridHeaders" data="secondGridData" areas=[B6:B6, B7:B7])
Then, to process the template, I used JxlsHelper.getInstance().processGridTemplate, because as @Matthias correctly mentioned, you can't use processGridTempalteAtCell, as it always expects exactly one grid.
Upvotes: 1
Reputation: 1264
You can have as many grids as you want on the right or bottom side. But you should be transforming the parent area which contains both of them.
GridCommandDemo from jxls-demo collection demonstrates the simple use case with a single grid. To adjust it for two grids you should modify your template to add additional grids and also modify the parent area (via lastCell attribute of jx:area command) to include all those grids.
In this case during the parent area transformation all the grids and static data will be properly shifted.
Upvotes: 4