Xlsx receipe each



  • I am new to jsreport. What I am trying to do is to create excel report with json data and align 2 tables side by side in the excel sheet. I am getting over and over the same error:

    Error while executing xlsx recipe
    (because) cannot read properties of null (reading 'parentNode')
    TypeError: Cannot read properties of null (reading 'parentNode')

    I use xlsx invoice example from the playground.



  • Please share the minimal playground demo replicating the problem so we can take a look.
    https://playground.jsreport.net/





  • Any thoughts?



  • It is Christmas vacation time, so getting the right people online will take some time. :)

    At first glance, there seems to be a problem with multiple each in one row. Maybe you can just use one each and use a helper call to merge those two arrays into one. Like here
    https://playground.jsreport.net/w/anon/5r07l9Fq



  • This partially solves my problem but I have 2 more issues:
    Firstly, what to do if I have two tables with an arbitrary number of rows which is needed to be displayed next to each other (unknown number of such rows)?
    Example: Table 1 has 8 rows; Table 2 has 10 rows.

    Secondly, is it possible to display header from one table and data from another table in the same row if we are using "each" in the template?
    Example: Table 1 starts from row number 1 and table 2 starts from row number 2.

    Thanks.



  • Hmm, it should still work in my example...
    A different number of items in both arrays works there.
    If you want a header for one and not for the other, you can just prepend the header and heave #each on the second row.
    If you need to have it dynamic, you will have #if for first item which will display header.



  • Could you please extend the example on the playground, because we are not able to produce what you wrote?



  • I tried many different scenarios but the second table always starts from the last row of the first table. I want to start from the third row (as defined in the excel template). Can you please help?

    https://playground.jsreport.net/w/anon/Y6esxzYm



  • Yes, I see.

    tried many different scenarios but the second table always starts from the last row of the first table.

    Unfortunately, this is how it works by design. We have no way of knowing if you want the content at the end of the first table or not. I've submitted a task to check if we can add a new option that would allow having two tables next to each other.
    https://github.com/jsreport/jsreport/issues/1198

    At this moment, one solution is to define cells contents including headers in the helper, and use a single each. To keep formatting, you will need to postprocess the xlsx using xlsx transformation helpers
    https://jsreport.net/learn/xlsx#transformation

    Demo
    https://playground.jsreport.net/w/anon/t9UNZpS4

    The other option is to use just xlsx transformation helpers from the beginning as this gives you the most flexibility.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.