Python Package openpyxl


Updated Aug 12th, 2021

I was so excited about this.

Macros may be easier, especially if you are on a work computer that is not allowed to install python or node. The “record macro” feature is also very badass so you don’t even need to learn VBA.

Never really leveraged this the way I should have given how exciting this ability is.

Here is the first test program I ran using the “openpyxl” library to programmatically create an excel workbook.:

from openpyxl import Workbook
from openpyxl.utils import get_column_letter

wb = Workbook()

dest_filename = 'empty_book.xlsx'

ws1 =
ws1.title = "firstSheet"
for row in range(1, 5): ws1.append(range(10))

ws2 = wb.create_sheet(title="secondSheet")

ws2['F5'] = 1994

ws3 = wb.create_sheet(title="thirdSheet")
for row in range(10, 20):
    for col in range(27, 54):
        _ = ws3.cell(column=col, row=row, value="{0}".format(get_column_letter(col)))

print(ws3['AA10'].value) = dest_filename)