Putting two dynamic grids beside each other with J

2019-05-23 14:38发布

问题:

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.

回答1:

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.



标签: jxls