python-docx-template icon indicating copy to clipboard operation
python-docx-template copied to clipboard

how use vm tag in secondary loop table

Open user-tq opened this issue 1 year ago • 4 comments

In the two-tier loop, vmtag doesn't seem to work as I expected. is there anyway to do this?

from docxtpl import DocxTemplate

tpl = DocxTemplate('templates/vertical_merge_vm_loop2.docx')
tpl.render(
    {"allinfo":
     [
         { "gene":"EGFR","varlist":[
                                    {"varname":"L858R","varwithdrugs":[
                                                                        {"drugname":"A1","druglink":"A11","druginfo":"A111"}
                                                                        ] 
                                                                            },
                                    {"varname":"T790M","varwithdrugs":[ {"drugname":"B1","druglink":"B11","druginfo":"B111"} ]  }

                                                                             ]
                                                                                    },
         { "gene":"ALK","varlist":[
                                    {"varname":"fusion","varwithdrugs":[
                                                                        {"drugname":"C1","druglink":"C11","druginfo":"C111"},
                                                                        {"drugname":"D1","druglink":"D11","druginfo":"D111"}
                                                                        ] 
                                                                            },
            

                                                                             ]
                                                                                    }
        
        
        ]
        
        }

)
tpl.save('output/vertical_merge_vm_loop2_out.docx')

vertical_merge_vm_loop2.docx

image

user-tq avatar Apr 10 '24 06:04 user-tq

I encountered the same problem

lumikenana avatar May 16 '24 02:05 lumikenana

你们解决了么?

mujianfenghe avatar Jun 28 '24 14:06 mujianfenghe

https://github.com/tsy19900929/docxtpl_dynamic_vertical_merging

33

tsy19900929 avatar Sep 08 '24 07:09 tsy19900929