Insert a row in Excel



  • Is it possible to insert a row into a specific position? The xlsxAdd only appends a row in the end.

    What I would like to accomplish is defining multi-sections in a spreadsheet (see the following screenshot) and add rows into each section.

    0_1500391125964_xlsx_sample.jpg


  • administrators

    hi! take a look at this example, here you can see how we add rows inside a loop at specific positions using xlsxAdd and using the r attribute of a <row> -> <row r="{{#sum 1 2}}{{/sum}}">.

    for your case i think you will need to do something very similar but i think you will need to also update the r attribute of all the rows that are bellow the sections that you are going to fill, and repeat the same steps for each section.



  • This is exact what I want. Thanks a lot, @bjrmatos !



  • https://playground.jsreport.net/studio/workspace/rkWcRiHog/27 in this example i need to group the data of same date for example i am having 2 data at 1st march and having 3 data at 1st march once again as per ur above example it comes in a next row . i need to display in same row of having 5 data in 1st march..in simple word i need to show like a pivot table


  • administrators

    @Hameed-Irfan does this example and steps help you in anything?



  • @bjrmatos yes this helps me but i need something more..like output of pivot table (NOT USING PIVOT TABLE)


  • administrators

    @Hameed-Irfan i think there is nothing special for what you are trying to do, you can group your data using just javascript, you just need to run some helper that groups and transforms your data in the shape you want and use those value to render the rows and cells of your excel file. i can't prepare an example for you that shows you this because it will take me some time. but here is some previous example (the example does not use xlsx recipe but you will get an idea) that shows how to run a helper to group your data and use it inside the template. the important part in the example is the helper, that can give you an idea of how to group your data, you just need to prepare some logic. also notice that you can require modules in helpers, so you can require lodash and use some of its utilities functions to group the data and make your work more easier.



  • ok @bjrmatos Tnks



  • I need to do something similar, but I get an excel error when I try to insert the row.

    I'm using <row r="">

    For example using the screenshot @Genhan-Chen provided, if I add the row to position 19 or above(20, 21, 22 etc), it will work, but when I try to add row to anything below it, the excel file shows an error and there is no data. Doesn't matter what row, I can try to add row to position 4 or 5 for example which are empty, I still get the error, and excel file opens with no data in it.


Log in to reply
 

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