Forum Discussion

EkremMese1's avatar
24 days ago

Storing Excel file's columns and rows into array with script testing

Hello everyone, 

I am working to create a method to randomly choose dropdown values from dropdown controls. But my dropdown values are changing based on what you choose in previous dropdown. For example:
If you choose a value for Region dropdown, Rayon dropdowns values are changing accordingly.

That's why I retrieve values from DataBase and create an excel source and I want my code to choose randomly. 

To do that, first I need to store the excel in a 2 dimensional array. 

Here is my Excel table:

Here is my code to store this excel in array:

function randomValueFromMultipleColumns() {
  //Initialize the external data source
  var Driver = DDT.ExcelDriver("C:\\Users\\Mes124360\\Desktop\\TestData\\TestData_EIDSS_V7.xlsx", "Simple" );

  //retrieve number of columns to use in the loop
  var columnCount = DDT.CurrentDriver.ColumnCount;
  //create an empty array to store the column names
  var tableArray = [];
  var columnsArray = [];
  //iterate through the columns to populate the array
  for (var i = 0; i < columnCount; i++) {
    var columnName = DDT.CurrentDriver.ColumnName(i);
  var rowCount = 0;

  for ( var i = 0; i < 3; i++) {
    var row = [];
    while(!Driver.EOF()) {


But when I run my code in the console I don't get what I expected:

Does anyone has an idea? 

2 Replies

  • rraghvani's avatar
    Champion Level 3

    You mentioned "2 dimensional array" -  is your variable actually storing data in a two dimensional array? And are you logging the output of a two dimensional array correctly?

    Hopefully, that should give you a hint.

    There's plenty of examples of JavaScript two dimensional array.

  • Marsha_R's avatar
    Champion Level 3

    What is your goal for choosing the values randomly? I think you may be working too hard at this.