Skip to content

Fills doc first table with data from excel by headers. I have added eval function to it. For example, you can type Addr+"\t"+Num and get the result of concatenation of cells from excel in your doc.

Notifications You must be signed in to change notification settings

ArhinZi/DocTableFromExcel-Filler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

DocTableFromExcel-Filler

Fills doc first table with data from excel by headers.

Autogenerated description

This Python script fills a table in a Microsoft Word document with data from an Excel workbook. The script takes four command-line arguments: the name of the Excel file, the name of the Word file, the row number to start reading from in the Excel file, and the number of rows to read.

The script uses the openpyxl library to open the Excel workbook and the docx library to load the Word document. It then gets the first table in the document and the header row of the table. The header row should contain temporary words that will be replaced with data from the Excel worksheet.

The script then loops through the specified rows in the Excel worksheet and adds a new row to the Word table for each row in the worksheet. It replaces the temporary words in the header row with data from the current row of the Excel worksheet using the eval() function, which evaluates a string as a Python expression. Before the eval() function is called, the script also replaces the Unicode quote characters in the temporary words with the appropriate ASCII quote characters to avoid any issues with encoding.

Finally, the modified Word document is saved with a filename starting with "0".

Note that this script should be used with caution as eval() can execute arbitrary code and may pose security risks if used with untrusted input.

About

Fills doc first table with data from excel by headers. I have added eval function to it. For example, you can type Addr+"\t"+Num and get the result of concatenation of cells from excel in your doc.

Resources

Stars

Watchers

Forks

Languages