How to save Xlsxwriter file in certain path?

user3496563 picture user3496563 · Apr 7, 2014 · Viewed 39.8k times · Source

Where does Xlsxwriter save the files you have created? Is it possibly to specify the path where I want the excel files to be saved?

My XlsxWriter script was in file /app/smth1/smth2/ and for some reason it saved the excel file to /app/. Shouldn't it have saved it in the same file where the script was? Or do I have to specify the path like this:

workbook = xlsxwriter.Workbook(' /app/smth1/smth2/Expenses01.xlsx')

What is the default file where the excel file is saved?

Answer

Steve Byrne picture Steve Byrne · Apr 7, 2014

Here's how you can save the file to the current directory (where your script is running from):

workbook = xlsxwriter.Workbook('demo.xlsx')

Here's how you can specify a full path:

workbook = xlsxwriter.Workbook('C:/Users/Steven/Documents/demo.xlsx')

Here's how you can specify a relative path:

workbook = xlsxwriter.Workbook('app/smth1/smth2/Expenses01.xlsx')

Note that a starting "/" is not needed and may cause errors.

More examples can be found here