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

question on creating complex vertical merged tab?

Open retsyo opened this issue 7 years ago • 6 comments

in my real work situation, I have to create a complex tab which you can read in the attachment

so, is there any way to implement it in python-docx-template?

in my demo docx file, there are only for categories(Book, DVD, Milk and Bag), but in fact I have many tables which has different numbers of categories, and varing number goods in every category.

category.docx

retsyo avatar Jan 15 '18 13:01 retsyo

I put your request to the enhancement wish list...

elapouya avatar Jan 16 '18 07:01 elapouya

Hi, how is it going with this enhancement? i have a similar table to create and I realized that jinja style template just doesn't accept any of my tries. It seems that nested FOR loops in one table is not possible. (see my examples) It also tried to correct the merging with docx but no luck... Tests_docx_tables.docx

Thanks in advance for improving this very promising package!

FlorenceMei avatar Jul 03 '20 13:07 FlorenceMei

it is better to transform

gauche = [[G11,G12,G13],[G21,G22,G23]]
droite = [[D11,D12,D13],[D21,D22,D23]]

into :

lignes = [[G11,G12,G13,D11,D12,D13],[G21,G22,G23,D21,D22,D23]]

So only one loop by row is needed.

elapouya avatar Jul 05 '20 08:07 elapouya

Yes, I did it that way only to test if it is possible to align several loops next to each other, but apparently not. Therefore, I would like to know if there is another way to write the second table in my docx file (the table I would like to have as result). It is a very similar problem of complex tables as proposed in the first post.

FlorenceMei avatar Jul 13 '20 16:07 FlorenceMei

Finally, I have to launch MsWord via win32com, then merge the cells by writing python code.

I do expect there will be an easy way without opening MsWord

retsyo avatar Jul 14 '20 00:07 retsyo

https://github.com/tsy19900929/docxtpl_dynamic_vertical_merging test1

tsy19900929 avatar Nov 04 '22 05:11 tsy19900929