In order to add a new entry in a table using openpyxl and Python, you can use the following steps:
load_workbook()
method of openpyxl
module.worksheet = workbook['Sheet1']
.table = worksheet.tables['Table1']
.new_row = ['value1', 'value2', 'value3']
where value1
, value2
, and value3
are the values that you want to add in the table.table.add_row(new_row)
method.workbook.save('example.xlsx')
method.Here's the code snippet that demonstrates these steps:
main.py418 chars20 lines
Make sure to replace the 'example.xlsx'
with the name of your workbook file and 'Sheet1'
and 'Table1'
with the name of your sheet and table, respectively.
gistlibby LogSnag