Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save Xlsxwriter file in certain path?

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?

like image 918
user3496563 Avatar asked Apr 07 '14 06:04

user3496563


People also ask

Is Openpyxl or XlsxWriter better?

If you are working with large files or are particularly concerned about speed then you may find XlsxWriter a better choice than OpenPyXL. XlsxWriter is a Python module that can be used to write text, numbers, formulas and hyperlinks to multiple worksheets in an Excel 2007+ XLSX file.


1 Answers

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

like image 182
Steve Byrne Avatar answered Sep 19 '22 09:09

Steve Byrne