Retrieve a specific cell’s value from a DataTable

Feb 19 2010

If you use WinAutomation to manipulate Excel files, you most likely came across the concept of Data Tables. Whenever you are reading a range of cells from an Excel file, the information that you acquire is stored in a variable that has a type of "Data Table". Sometimes, you may want to retrieve a specific cell's value. The easiest way to do that, is to use the "Read from Excel" action, and store a cell's content into a variable. But what happens if you need to use the values of 50 different cells from the Excel file? Do you have to create 50 different "Read From Excel" actions? Of course not. In such a case, all you have to do is read a range of cells and then use them in your job through the special notation that accompanies data tables.

In order to retrieve a specific item of a data table, you will have to use the following notation: %VariableName[RowNumber][ColumnNumber]%. Keep in mind that “RowNumber” and “ColumnNumber” should be 0 for the first item (row or column), 1 for the second and so on. For example, if you have a data table that is stored in the variable %ExcelData%,

you can retrieve the first item with: %ExcelData[0][0]% and the last item with %ExcelData[ExcelData.RowsCount-1][ExcelData.Columns.Count-1]%

Also, if your data table has named columns, you can use the following notation to retrieve a cell’s value:
%VariableName[RowNumber]["ColumnName"]%

Your rating: None Average: 5 (2 votes)

Post your comment

You!
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may quote other posts using [quote] tags.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.