Pretty much, I have the following code, generating an Excel file.
import xlsxwriter myName = 'hello.xlsx' wbk = xlsxwriter.Workbook(myName)
hello.xlsx is generated in the same directory, where the Python file is. I can refer to the file path easily like this:
import os print (os.getcwd()+"\"+myName)
However, is there a way to refer to the path, only using only
wbk? Something like
wbk.Path from vba.
However, is there a way to refer to the path, only using only wbk
The Workbook object only sees, and stores, the filename that is passed to it by the user. So if the user doesn’t pass the path then the object can’t store it.
I’d suggest using
os.getcwd() like in your example.