Get all values from one column of Excel data source?

Ask general questions here.
mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Get all values from one column of Excel data source?

Post by mrt » Thu Jun 24, 2021 2:12 pm

Hey folks,

I am pretty sure there is a simple and efficient code snippet to obtain all values from a given column of an Excel data source.

May you please help me out? :)

thanks, BR mrt

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Get all values from one column of Excel data source?

Post by Fergal » Fri Jun 25, 2021 10:19 am

mrt what do you want to do with those values / how do you wish to use them?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get all values from one column of Excel data source?

Post by odklizec » Fri Jun 25, 2021 10:37 am

Hi,

This code should help:

Code: Select all

    //get cur test container
    var curTestCase = (TestCaseNode)TestSuite.CurrentTestContainer;
    //get all the rows of the data source that is currently set
    Ranorex.Core.Data.RowCollection rows = curTestCase.DataContext.Source.Rows;
    //enumerate rows from data source
    foreach (Ranorex.Core.Data.Row rowItem in rows)
    {
        // get value of given column and actual row iteration
        string rowItemVal= rowItem.Values[curTestCase.DataContext.Source.Columns["ColName"].Index];
    }
Pavel Kudrys
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

mrt
Posts: 257
Joined: Mon Mar 16, 2020 11:31 am

Re: Get all values from one column of Excel data source?

Post by mrt » Mon Jul 05, 2021 2:12 pm

works, thank you!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get all values from one column of Excel data source?

Post by odklizec » Tue Jul 06, 2021 10:28 am

Hi,

Good to hear that ;)
Pavel Kudrys
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