Despite the various Python Excel-manipulation libraries and resources, I am unable to find a specific solution.
Right now, I have a template Excel file where a table exists. I would like to write a Python program in order to populate this table. Is this possible with any of the existing Excel libraries? The template Excel file has a sheet with an empty table (1st screenshot). I want to programmatically populate the table with some data from elsewhere. e.g.

data = [("TS0001", "1.0 Administration", "Root", "vdouk", "15/09/19", 8.0, "example 1"),
("TS0002", "1.0 Administration", "Root", "vdouk", "16/09/19", 3.0, "example 2"),
("TS0003", "4.0 Simulations", "Root", "vdouk", "16/09/19", 5.0, "example 3")]
Thus, I want finally to look like the 2nd screenshot. The total entries and subtotals are computed automatically from appropriate excel cell functions (already defined). Finally, note that this table is referenced from other parts of the workbook, meaning that it is a named data source (seen in the Excel name manager), so defining a new table will cause problems elsewhere. Can someone direct me to the most appropriate solution?

Right now, I am using openpyxl. The workaround I do is to edit the template .xlsx and add empty rows to the table. Then I write as many rows as my data tuples are by using openpyxl. The table totals seem to work, however some other excel macros seem to be breaking.
You may not update excel file with any existing Python modules but you can override the existing file with Openpyxl module.
With help of Openpyxl module you can read existing worksheet in memory append your new content and save it back to the same file:
from openpyxl import load_workbook
#Open an xlsx
wb = load_workbook(filename = 'data.xlsx')
#Get the current Active Sheet
ws = wb.get_active_sheet()
#ws = wb.get_sheet_by_name("Sheet1")
# Get the row and column index in which you are going to write
ws.cell(1,1).value = 'your_value'
# save() will override existing file
wb.save('data.xlsx')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With