Openpyxl in Python to write some data in an Excel file using Workbook.
When I want to save the workbook to a file, I can only provide a filename argument, so I can not write files in other directories.
here is my sample code:
import openpyxl file_name = "sample.xlsx" wb = openpyxl.Workbook() # writing some data to workbook wb.save(filename=file_name)
I have checked the documentation via this link and found nothing more.
Can you help me provide workarounds to solve this problem?
Oh it’s not hard and completely as others Python methods
So just use the full file path
import openpyxl file_path = "/your/path/here/sample.xlsx" wb = openpyxl.Workbook() wb.save(filename=file_path)