Hi,
Out of curiosity wanted to know is there any possiblity to access and manupulate data in and from the excel without using the Inbuilt excelconnector GUI function can we do it by writing some code in Ranorex studio 5.2 ?
If it is possible Please let me know how to do it.
Regards
Nishant Singh
How to access data from excel using the code
-
- Posts: 39
- Joined: Thu Oct 09, 2014 1:15 pm
- Location: Bangalore
How to access data from excel using the code
Regrads,
Nishant Singh
Nishant Singh
Re: How to access data from excel using the code
Ranorex is built on .NET, so anything you can do with .NET you can do with Ranorex.
A couple of things to note:
1. It is NOT advisable to manipulate test data during the test run.
2. You will need to know how to write .NET code.
Use the .NET Office Interoperability library just like you would any other library. There are numerous examples of how it works on the web.
A couple of things to note:
1. It is NOT advisable to manipulate test data during the test run.
2. You will need to know how to write .NET code.
Use the .NET Office Interoperability library just like you would any other library. There are numerous examples of how it works on the web.
Shortcuts usually aren't...
Re: How to access data from excel using the code
Hi,
Hope below peace of code will help to read Excel File in the ranorex code modules.
Excel.Application excelFile = new Excel.ApplicationClass();
Excel.Workbook excelWB= excelFile.Workbooks.Open(path);
Excel.Worksheet excelWS=(Excel.Worksheet) excelWB.Worksheets.get_Item(sheetName);
Exce.Range tmpRange=(Excel.Range)excelWS.Cells[1,1];
sting cellText=tmpRange.Text.ToString();
Regards,
Nagarjuna
Hope below peace of code will help to read Excel File in the ranorex code modules.
Excel.Application excelFile = new Excel.ApplicationClass();
Excel.Workbook excelWB= excelFile.Workbooks.Open(path);
Excel.Worksheet excelWS=(Excel.Worksheet) excelWB.Worksheets.get_Item(sheetName);
Exce.Range tmpRange=(Excel.Range)excelWS.Cells[1,1];
sting cellText=tmpRange.Text.ToString();
Regards,
Nagarjuna
-
- Posts: 39
- Joined: Thu Oct 09, 2014 1:15 pm
- Location: Bangalore
Re: How to access data from excel using the code
Hi Nagarjuna,
Thanks for the code script I already got that from other sources. but anyways thanks for reponse.
regards,
Nishant Singh
Thanks for the code script I already got that from other sources. but anyways thanks for reponse.
regards,
Nishant Singh
Regrads,
Nishant Singh
Nishant Singh
Re: How to access data from excel using the code
This is very helpful code to access data from any excel file with the help of code. Thanks to share this with us...
Re: How to access data from excel using the code
Can you please let me know how the path of the excel document need to be given , as I have tried couple of ways but getting error
1) I have my excel sheet with in the project folder as
C:\\MyRanorex\\TripMaker_Consumer\\InputData.xls
2) The code I have written is
Excel.Application excelFile = new Excel.ApplicationClass();
Excel.Workbook excelWB = excelFile.Workbooks.Open("C:\\MyRanorex\\TripMaker_Consumer\\InputData.xls");
Excel.Worksheet excelWS = (Excel.Worksheet)
excelWB.Worksheets.get_item(Sheet1);
Excel.Range tmpRange = (Excel.Range)excelWS.Cells[1,1];
string value = tmpRange.Text.ToString();
Report.Info(value);
Please correct me with the right information
1) I have my excel sheet with in the project folder as
C:\\MyRanorex\\TripMaker_Consumer\\InputData.xls
2) The code I have written is
Excel.Application excelFile = new Excel.ApplicationClass();
Excel.Workbook excelWB = excelFile.Workbooks.Open("C:\\MyRanorex\\TripMaker_Consumer\\InputData.xls");
Excel.Worksheet excelWS = (Excel.Worksheet)
excelWB.Worksheets.get_item(Sheet1);
Excel.Range tmpRange = (Excel.Range)excelWS.Cells[1,1];
string value = tmpRange.Text.ToString();
Report.Info(value);
Please correct me with the right information
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to access data from excel using the code
Hello svelaga,
Please try to use the following code:
Regards,
Robert
Please try to use the following code:
Code: Select all
…Open(@"C:\MyRanorex\TripMaker_Consumer\InputData.xls");
Robert