Forum Discussion
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.
- Jainsoumya3 years agoContributor
Marsha_R I tried doing like getting a value of row or column but then also excel file didnt get open
function ReadDataFromExcel()
{
let Excel = getActiveXObject("Excel.Application");
Excel.Workbooks.Open("C:\\Users\\Public\\TestInput\\ChartInput.xlsx");let RowCount = Excel.ActiveSheet.UsedRange.Rows.Count;
let ColumnCount = Excel.ActiveSheet.UsedRange.Columns.Count;for (let i = 1; i <= RowCount; i++)
{
let s = "";
for (let j = 1; j <= ColumnCount; j++)
s += (VarToString(Excel.Cells.Item(i, j)) + "\r\n");
Log.Message("Row: " + i, s);
}}
- Marsha_R3 years agoModerator
Try this. Do you get the message in your log?
var excelFile = Excel.Open("C:\\Users\\Public\\TestInput\\ChartInput.xlsx");
log.message("This is my excel test message.")
var excelSheet = excelFile.SheetByTitle("Sheet1"); - AlexKaras3 years agoChampion Level 3
Hi,
> excel file didnt get open
Can you provide your definition of "Excel file been opened" ? What do you expect to get?
Related Content
Recent Discussions
- 43 minutes ago
- 6 days ago
- 10 days ago