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?
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.
Install and Import openpyxl
import openpyxl
Create new workbook
wb = openpyxl.Workbook()
Get SHEET name
Sheet_name = wb.sheetnames
Save created workbook at same path where .py file exist
wb.save(filename='Test.xlsx')
这在文档中有介绍: https : //openpyxl.readthedocs.io/en/stable/tutorial.html#saving-to-a-file
wb.save(…)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.