Closed demiwang1214 closed 3 years ago
Currently tables with <tbody>
aren't supported. For now I'd suggest using a workaround of removing the tbody tags from the html before feeding it to add_html_to_document(). E.g.
html = re.sub('</*tbody>', '', html)
new_parser.add_html_to_document(html, docx)
(The way this whole package is managed is pretty terrible. I'm looking at cleaning that up first before adding a fix).
@pqzx thank you for response. i added your workaround, no exception happen now, but the table inline styles didn't display properly, such as table border and cell width didn't display, can it be improved? do you have any suggestion?
This isn't currently supported. Could be worth adding.
https://python-docx.readthedocs.io/en/latest/api/table.html#docx.table.Table https://python-docx.readthedocs.io/en/latest/api/table.html#docx.table._Column
I got it working for me. Opened a PR here: https://github.com/pqzx/html2docx/pull/7
convert html table to docx, but got error as below. html table is from tinymce
html='
can anyone help me? thanks