I’m trying to use IronPython to export a series of Excel Worksheets to delimited text files using Interop. I I think I should be using the SaveAs method, but I’m not clear what the equivalent python syntax is for it. My current code keeps the worksheet in Excel format because the most obvious syntax would be SaveAs(file ".txt", olTXT), but this fails.
import clr
clr.AddReferenceName('Microsoft.Office.Interop.Excel')
import Microsoft.Office.Interop.Excel as Excel
xl = Excel.ApplicationClass()
xlFiles = open('\path\to\files.xls', 'r')
for file in xlFiles:
wb = xl.Workbooks.Open(file)
ws = wb.Worksheets(1)
ws.SaveAs(file ".txt")
How should I use it? If you have a reference better than Interacting with Excel, let me know. Thanks for your help!
ws.SaveAs(file “.txt”, Excel.XlFileFormat.xlUnicodeText) was what I was looking for. I found that here