Adding Merged Cells Xlsx



  • Hi

    I am trying to add merged cells to an existing excel file that already has other merged cells.
    Unfortunately when using the xlsxReplace helper as shown in the documentation it will obviously remove all existing mergedCell elements from the mergedCells Node.

    {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.mergeCells"}}
                <mergeCells>
                    <mergeCell ref="C12:G12"/>
                </mergeCells>
    {{/xlsxAdd}}
    
    {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.mergeCells"}}
    
                    <mergeCell ref="C12:G12"/>
    
    {{/xlsxAdd}}
    

    I have tried using the add helper like above but it breaks the excel file.

    Is there a way I can achieve what I want without breaking the existing merged cells in the file?



  • It should be like this

    {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.mergeCells[0].mergeCell"}}    
        <mergeCell ref="C1:D2"/>    
    {{/xlsxAdd}}
    

    Example
    https://playground.jsreport.net/w/anon/lx9BZcZD


    The second parameter is the path inside the JSON which is parsed from the XML. Try to log how that json looks to find how the path should look like.
    https://playground.jsreport.net/w/anon/ryaUvq21e-3



  • Thank you so much will keep the logging of the json in mind. its really helpful


Log in to reply
 

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