Jsreport xlsx with multiple tables on same sheet
-
Hi,
I have an .xlsx file that I have imported as an asset. In it I have configured in Sheet1 three tables.
Table1: A, B columns
Table2: E, F, G columns
Table3: L,M columns
base on which I have added Named Ranges for each column with offset and counta. Those ranges I use in other sheets in same xlsx file to show different types of graphs. So far so good. All of that set up in the xlsx asset file works fine
Then I have created a new template in jsreport studio with xlsx and handlebars. This template uses the asset mentioned above.
Then I iterate with {{#each}} three data collections I have in order to fill in the data in the three table. In order to put the data in the right column, I am using the "r" attribute of the cell. This also works fine
What is not working is that the tables are not filled in from row 1, but sequentially. If first {{#each}} stops on row 5, then the second {{#each}} will start filling data from the row 5. With the help of an AI tool I found out this is normal behavior of handlebars {{xlsxAdd}}. It adviced me to use {{xlsxMerge}} , but then It does not fill in any data at all.
P*S I have inner {{#each}} in the structure that prints the data
Would you please help me understand how to print the data in the three tables at the right columns, but starting from 2nd row (to respect the headers)
-
I am adding a playground link
https://playground.jsreport.net/w/teodora.gardjeva-pesheva/YUe5Y7~q
As you can see, the data is filled in sequentially. It iterates from the first row, but can not fill in the cells if another table already filled them in
The tables are filled in the following order: table3, table1, table2
-
hi!
it seems the problem is how your loops are generating the rows
in your first each you are generating: R2, R3 ... R6
the second each you are generating: R2, R3 ... R7
the third each you generate: R2, R3, R4basically you are generating duplicated rows, and because of that when you see the file, the preview tries to self-repair the duplicated rows by given them new indexes, so that is why you your content being generated at different rows.
there are a lots of ways you can fix this, but the most simple i think is to group your data and in single loop generate all the rows that you need