Forum Discussion
rraghvani
Champion Level 3
15 hours agoHow are you accessing Excel via COM or Excel Object?
You can either create your own method to perform the comparison (shown in In Script Tests) or use the Excel Checkpoints.
Working with Excel COM gives you more flexibility, and there's plenty of examples on the Internet. It does require Excel to be installed though. Whereas, Excel Object has limited functionality and is specific to TestComplete.
Snippets of code to access work sheets,
wb = excel.Workbooks.Open(r"C:\path\file.xlsx")
sheet1 = wb.Worksheets(1) # Accessing sheet via index
sheet2 = wb.Worksheets(2)
sheet1 = wb.Worksheets("Sheet1") # Accessing sheet via name
sheet2 = wb.Worksheets("Sheet2")
Log.Message(wb.Worksheets.Count) # Number of worksheets
# Loop through all worksheets
for sheet in wb.Worksheets:
Log.Message(sheet.Name)