Contents

openpyxl code example

0
Contents

A complete example that exposes prometheus metrics endpoint under /metrics/ path in starlette.

from openpyxl import Workbook
wb = Workbook()

# grab the active worksheet
ws = wb.active

# Data can be assigned directly to cells
ws['A1'] = 42

# Rows can also be appended
ws.append([1, 2, 3])

# Python types will automatically be converted
import datetime
ws['A2'] = datetime.datetime.now()

# Save the file
wb.save("sample.xlsx")

Code example provided by the project.

About openpyxl

openpyxl - a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files.