how to create a new xlsx file using openpyxl?

Newboy11 picture Newboy11 · Aug 8, 2015 · Viewed 34.3k times · Source

Does anybody knows how to create a new xlsx file using openpyxl in python?

filepath = "/home/ubun/Desktop/stocksinfo/yyy.xlsx"
wb = openpyxl.load_workbook(filepath)
ws = wb.get_active_sheet()

What do I need to add?

Answer

Newboy11 picture Newboy11 · Aug 8, 2015

I'm sorry my head is turning around. :) This solves the problem

filepath = "/home/ubun/Desktop/stocksinfo/test101.xlsx"
wb = openpyxl.Workbook()

wb.save(filepath)

This will create a new file.