bsuire
bsuire

Reputation: 1483

Preserve formatting when modifying an Excel (xlsx) file with Python

Is there any Python module out there that can be used to create an Excel XLSX file replicating the format from a template?

Upvotes: 2

Views: 4775

Answers (2)

Compadre
Compadre

Reputation: 834

As far as I understood openpyxl supports this. This is example from docs:

from openpyxl import load_workbook

wb = load_workbook('sample_book.xltx') 
ws = wb.active 
ws['D2'] = 42 

wb.save('sample_book.xlsx') 

Upvotes: 2

sTr8_Struggin
sTr8_Struggin

Reputation: 675

You can use openpyxl to open a template file and then populate it with data and save it as something else to preserve the original template for use later. Check out this answer: Working with Excel In Python

Upvotes: 0

Related Questions