Read excel

Bug reports.
Balachandrav
Posts: 3
Joined: Wed Aug 28, 2019 10:35 am

Read excel

Post by Balachandrav » Mon Sep 09, 2019 1:31 pm

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);

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: Read excel

Post by RobinHood42 » Tue Sep 10, 2019 7:41 am

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

vishantpandey
Posts: 2
Joined: Wed Aug 04, 2021 9:26 am

Re: Read excel

Post by vishantpandey » Wed Aug 04, 2021 9:31 am

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);
} 

vishantpandey
Posts: 2
Joined: Wed Aug 04, 2021 9:26 am

Re: Read excel

Post by vishantpandey » Wed Aug 04, 2021 9:37 am

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);
}