Forum Discussion

lokithorshield's avatar
lokithorshield
Contributor
10 years ago

Access Random Row

Hi Why is there no Random access to a Excel row using either DDT or DBTable. I had to write code to ensure this happens via COM driver.

 

Thanks,

Mahesh

3 Replies

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      I find the built in Excel access too limited.

       

      I have script extensions which use Excel via COM which allow for much more complex interactions. Mine allows for some basic conditional logic so a test step can check if previous step(s) passed or not and run (or not) based on the outcome of the previous tests. (Markers & Dependencies) It allows the test to run over known bugs. When the bug is fixed, and the failing test starts passing, I don't need to change anything. The conditional logic will simply stop running the corrective actions.

       

      My entire test framework - Excel test/data drivers - log files - screen captures - various summary outputs (HTML file, e-mail, Excel summary) - is controlled by Script Extensions. All I need to worry about is writing test functions. :)

       

      (And then the testers just need to worry about building test packs with them)

      • lokithorshield's avatar
        lokithorshield
        Contributor

        Yes I wrote a code too... I use MS Excel Range Object, predefine the column to search for reference to retreive data and iterate or pickk up

        1. group of rows // sequential or not

        2. Single Row

        3. Randow set of rows at one go

        4. Randow row

         

        5. Random rows in Sequnce as passed in a array by driver script.. .. its too flexible

        , but its not preferred inside our organization as it needed for code to be written  and prefer DDT / DBVar as its inbuilt. At least thats what they said when they rejected my code. !!!

         

        with (sheet.Range("A:A")) //The excel reference value should be in column here, else change as needed
        {
        cellVal1 = cellVal;
        cellFirst = cellVal;
        cellVal = null;
        cellVal = Find(recvField[0]); //Find the row to be retreived - Row value passed to this function.

         

        while ((cellVal != null) ) //Get the values if found something
        {

           cellVal = FindNext(cellVal1);

        ..... Etc

         

        Thanks,

        Mahesh