Ask a Question

how to open excel file using TestComplete

Jainsoumya
Contributor

how to open excel file using TestComplete

@Marsha_R

I am not able to open excel file using this methd , though its is getting passed but required action is not taking place

function ExcelExample()

{
// Get the sheet of the Excel file
var excelFile = Excel.Open("C:\\Users\\Public\\TestInput\\ChartInput.xlsx");
var excelSheet = excelFile.SheetByTitle("Sheet1");


}

 

12 REPLIES 12
Marsha_R
Champion Level 2

What is happening when you try this?

Jainsoumya
Contributor

@Marsha_R  No action is taking place , script just got passed thats it.

Your syntax is correct, so I would first look for an issue with file permissions. Make sure that TestComplete has access to that particular directory. You could try putting the Excel file on the desktop to begin with, just to confirm the permissions.

Hi,

 

No action is taking place

What action do you expect?

Note, that Excel object provided by TestComplete does not require Excel application to be installed and thus does not provide any UI.

If you need to open the file in Excel application, then you must start Excel as a COM object and use its object model. (https://support.smartbear.com/testcomplete/docs/testing-with/working-with-external-data-sources/exce... as an example)

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================

@Marsha_R  I have tried this but no result , script got passed but no required action took place

@AlexKaras 

I have tried this two methods and script got passed but required excel file didnt get open 

 

function ReadDataFromExcel()
{
let Excel1 = Sys.OleObject("Excel.Application");
Excel1.Workbooks.Open("C:\\Users\\Public\\TestInput\\ChartInput.xlsx");



}

 

and 

function ReadDataFromExcel()
{
let Excel = getActiveXObject("Excel.Application");
Excel.Workbooks.Open("C:\\Users\\Public\\TestInput\\ChartInput.xlsx");


}

npaisley
Staff

Hi @Jainsoumya!

 

No action is taking place, because there is no action to perform in the code sample.

 

In the small sample above, TestComplete is simply opening and closing the sheet in the background.

 

Since there is no other action, such a Log event to post results, nothing is being returned. 

 

Is there another action further down in your code that is not working? If you are only running the snippet provided, then no results in your logs is going to be the expected result.


Regards,
Nick

Solutions Engineer @ SmartBear

@npaisley  so what is the code to open the required excel file ?

You have the correct code to open the file but what @npaisley is saying is the open does not count as an action for TestComplete so it does not log it.  The file has been opened  in the background and nothing is visible. Same for the sheet reference.  You set it to a variable but this is not a logged action.

 

Try doing something next like getting a value from the sheet and putting it in a log message. That will show an action.

cancel
Showing results for 
Search instead for 
Did you mean: