Page 1 of 1

Read excel

Posted: Mon Sep 09, 2019 1:31 pm
by Balachandrav
Hi,

How to read excel column headers in ranorex user code?

With below code am able to read data but not headers:

Ranorex.Core.Data.ExcelDataConnector excelConnector = new Ranorex.Core.Data.ExcelDataConnector("excelConnector",sTestData + ExcelFileName + ".xlsx","Sheet1","A:A",System.Windows.Forms.CheckState.Unchecked);
Ranorex.Core.Data.ColumnCollection columnCollection;
Ranorex.Core.Data.col
Ranorex.Core.Data.RowCollection rowCollection;
excelConnector.LoadData(out columnCollection, out rowCollection);

Re: Read excel

Posted: Tue Sep 10, 2019 7:41 am
by RobinHood42
Hi,

It's not a good idea to access or even modify data using the Ranorex Excel data connector. I would highly recommend using the official Microsoft.Office.Interop to do so: Example: https://coderwall.com/p/app3ya/read-excel-file-in-c

Cheers,
Robin

Re: Read excel

Posted: Wed Aug 04, 2021 9:31 am
by vishantpandey
1.Install Nuget Package of IronXL into your project.
2.Now you can access all excel operations like create, load, read e.t.c through IronXL in various formats like XLSX, XLS, CSV and TSV .
3.Follow the link: https://ironsoftware.com/csharp/excel/t ... le-csharp/

Code: Select all

WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet sheet = workbook.WorkSheets.First();
//Select cells easily in Excel notation and return the calculated value
int cellValue = sheet["A2"].IntValue;
// Read from Ranges of cells elegantly.
foreach (var cell in sheet["A2:A10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
} 

Re: Read excel

Posted: Wed Aug 04, 2021 9:37 am
by vishantpandey
1.Install Nuget Package of IronXL into your project.
2.Now you can access all excel operations like create, load, read e.t.c through IronXL in various formats like XLSX, XLS, CSV and TSV .
3.Follow the link: Excel in C# tutorial

Code: Select all

WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet sheet = workbook.WorkSheets.First();
//Select cells easily in Excel notation and return the calculated value
int cellValue = sheet["A2"].IntValue;
// Read from Ranges of cells elegantly.
foreach (var cell in sheet["A2:A10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}