egood
egood

Reputation: 21

xlwings saves workbook as web page, need to save as 97-2003 workbook (.xls)

xlwings' workbook.save method is saving excel files as webpages, I need to save them in .xls format.

I am pulling the excel files from a website and I believe that's why they are defaulting to save as a webpage. I've tried using:

import xlwings as xw
wb = xw.Workbook("Full path name\\template.xls")
'''some formatting code'''
wb.save("New path name\\formatted_template.xls")

I've also tried saving to the default directory:

wb.save("formatted_template.xls")

In both cases it returns .xls files saved as webpages. The only way I can save them in .xls format (not as webpages) would be to keep all files open and manually save as .xls for each one, but this would be much more time consuming than if I could automate the process.

I apologize if I've missed any posting etiquette as this is my first post.

Any feedback would be appreciated.

Thanks

Upvotes: 1

Views: 1065

Answers (1)

Felix Zumstein
Felix Zumstein

Reputation: 7070

Yeah, currently the option to save a workbook as a certain type is not natively supported yet. Use this workaround instead for now (Windows version):

import xlwings as xw
from xlwings.constants import FileFormat
wb.api.SaveAs(your_path, FileFormat.xlExcel8)

Upvotes: 2

Related Questions