Troubleshooting creating an Excel file in TestComplete (using Python)
I am pretty well using the standard sample code from the main TestComplete site.
def writeExcel():
# https://support.smartbear.com/testcomplete/docs/testing-with/working-with-external-data-sources/excel/write.html
# https://support.smartbear.com/testcomplete/docs/testing-with/working-with-external-data-sources/excel/open.html
#curTime = aqDateTime.Now()
emailDataFilename = r'C:\foo\bar\redacted.xlsx'
Log.Message(aqString.Format("Data file name is %s.",emailDataFilename))
if (aqFile.Exists(emailDataFilename)):
excelDataFile = Excel.Open(emailDataFilename)
else:
# Create a new Excel file and add a new empty sheet to it
Log.Message(aqString.Format("The %s file does not exist and will be created.", emailDataFilename))
excelDataFile = Excel.Create(emailDataFilename)
excelSheet = excelDataFile.AddSheet("Sheet1")
The if/else logic works fine, but nothing happens in terms of file activity.
Hello DSmachineWorld -
excelFile.Save()
Please add this and it should be fixed! Let me know if you have further questions.
Emma