How to save Xlsxwriter file in certain path?

我们两清 提交于 2019-11-27 05:57:28

问题


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?


回答1:


The file it's self is saved to your local directory (where you run the file from) for example, I am using Python 2.7.6, and when I run this:

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

The file is saved in the same folder as my Python file, you can also specify a full path like so:

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

And this will save my demo.xlsx file in my documents folder (assuming you are on windows) Make sure all of your paths are correct (case sensitive, and none corrupted) and it should work, the final example that should be a copy and paste for you is:

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

Notice the starting "/" is not needed and may be causing your errors (at least on Windows, I can't say for sure on Mac/Linux). Best of luck! Examples can be found here



来源:https://stackoverflow.com/questions/22904654/how-to-save-xlsxwriter-file-in-certain-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!