'Copy table from excel to word with the style
I am working with a word file using python-docx, I want to copy an excel table with style in this open document (word file)
I found this code in internet, but here doc file is defined word.Documents.Open('C:\Users...\test.docx')
from win32com import client
excel = client.Dispatch("Excel.Application")
word = client.Dispatch("Word.Application")
doc = word.Documents.Open('C:\\Users\...\test.docx')
book = excel.Workbooks.Open('C:\\Users\...\test.xlsx')
sheet = book.Worksheets(1)
sheet.Range("A1:O11").Copy()
doc.Content.PasteExcelTable(False,False,False)
while in my current code from python-docx
from docx import Document
document = Document()
I would be more than grateful if you respond me. Also all other suggestions regarding table styles are appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
