How to save Xlsxwriter file in certain path?
Asked Answered
N

1

17

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?

Neurosurgery answered 7/4, 2014 at 6:2 Comment(3)
RTFM man. A 30-sec google got me here where it says that xlsxwriter.Workbook('Expenses01.xlsx') takes the file name as an argument.Remissible
My script was in file /app/smth1/smth2/ and for some reason it saved the file to /app/. Shouldn't it have saved it in the same file where the script was? This is why I'm asking this question. Or should I have specified the path workbook = xlsxwriter.Workbook(' /app/smth1/smth2/Expenses01.xlsx') for the file to have been saved in this path?Neurosurgery
This is an entirely different question - I advise you to fix your question accordingly. I suspect that you should specify the full path as the argument.Remissible
L
29

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

Lionhearted answered 7/4, 2014 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.