Hi All,
I have seen a lot of posts about excel's.
Nut never got a satifying answer. All the code's given are complicated.
Scenario: I want to write data in different rows
Example: Coloumn "A" and rows 1 to 5.
How can I do that.
nd do i have to add some references to open excel?
Please Reply.
Regrards,
Deepak
Problem With Excel
-
- Posts: 76
- Joined: Fri Mar 14, 2014 2:37 pm
Problem With Excel
Last edited by Support Team on Fri May 16, 2014 7:18 am, edited 1 time in total.
Reason: offensive title
Reason: offensive title
Re: Problem With Excel!!!
Hi Deepak,
The other day I did some automation on excel 2013. It went well
Just some things to make sure of:
- the ribbon should be always visible. Or use mousemoves, so the ribbon will stay visible.
- do not use automation on excel
If you want to use it for creating and manipulating data, then use excel's built-in functions and macro programming. If you want to use it to create report, just use macros, and use ranorex .csv connectors to store data generated on the fly.
Why do you want to use Ranorex on excel automation in the first place anyway?
Best Regards,
Zoltan
The other day I did some automation on excel 2013. It went well

Just some things to make sure of:
- the ribbon should be always visible. Or use mousemoves, so the ribbon will stay visible.
- do not use automation on excel

Why do you want to use Ranorex on excel automation in the first place anyway?
Best Regards,
Zoltan
-
- Posts: 76
- Joined: Fri Mar 14, 2014 2:37 pm
Re: Problem With Excel!!!
The Problem is that I want to store the Actual REsults in Excel.
Just that Plz help.
Ex:
Depending on the Condition I want to store the Result in Excel. How will I do that?
Regards,
Deepak
Just that Plz help.

Ex:
Code: Select all
If(repo.Ranorex.Ranorex.exists())
{
String x="Button Exists";
}
else
{
String x="Button Does not Exists";
}

Regards,
Deepak

Re: Problem With Excel
Hi,
I'm afraid, there is not a direct (easy-to-use-without-coding) way how to write something to Excel. Below you can find a quick&dirty sample code how to write a string to an existing excel file (cell 1,1). It's just a rough example, which you will most probably have to adapt according your needs.
Other ways how to write something to excel are nicely summarized here:
http://www.ranorex.com/forum/writing-ex ... t1605.html
I personally would suggest to use Ranorex CSV data connector interface, which does not require Excel to be installed on the target machine.
I'm afraid, there is not a direct (easy-to-use-without-coding) way how to write something to Excel. Below you can find a quick&dirty sample code how to write a string to an existing excel file (cell 1,1). It's just a rough example, which you will most probably have to adapt according your needs.
Other ways how to write something to excel are nicely summarized here:
http://www.ranorex.com/forum/writing-ex ... t1605.html
I personally would suggest to use Ranorex CSV data connector interface, which does not require Excel to be installed on the target machine.
// path to excel file string xlsPath = @"c:\temp\rxtest.xls"; // desired sheet name string currentSheet = "Sheet1"; // initialize excel Excel.Application excelDataSourceFile = new Excel.ApplicationClass(); // makes excel invisible excelDataSourceFile.Visible = false; // opens excel file Excel.Workbook excelWorkbook = excelDataSourceFile.Workbooks.Open(xlsPath); Excel.Sheets excelSheets = excelWorkbook.Worksheets; // set active sheet Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet); excelWorksheet.Activate(); // write something to cell 1,1 excelDataSourceFile.Cells[1,1] = "Button Exists"; // save excel file excelWorkbook.Save(); // close excel file excelWorkbook.Close();
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
-
- Posts: 76
- Joined: Fri Mar 14, 2014 2:37 pm
Re: Problem With Excel
For Future Reference.This will help: Just Copy and Paste from here.
Regards,
Deepak
Code: Select all
Excel.Application myExcelApp;
Excel.Workbooks myExcelWorkbooks;
Excel.Workbook myExcelWorkbook;
object misValue = System.Reflection.Missing.Value;
myExcelApp = new Excel.ApplicationClass();
myExcelApp.Visible = true;
myExcelWorkbooks = myExcelApp.Workbooks;
String fileName = "C:\Change_Password_Blank_spaces.xls";
// set this to your file you want
myExcelWorkbook = myExcelWorkbooks.Open(fileName);
myExcelApp.Cells[row,Coloumn]="Step Failed!!!";
myExcelWorkbook.Save();
myExcelApp.Visible = false;
myExcelWorkbook.Close();
Regards,
Deepak
