Forum Discussion
torus
23 days agoFrequent Contributor
You might already be aware of the below but it took me a while to figure out ...
Additionally, for some tables, it is not always obvious how to retrieve a cell and retrieve the cell data (because of the objects the developer used to create the table).
Sometimes you can access table data as you would expect (like you would in Excel) using the table.Cell(row,column) function like shown below:
function getRow()
{
var table = Aliases.MyApp.ATable;
var numOfRows = table.RowCount;
var foundRow = -1;
for(let row = 0; row < numOfRows; row++)
{
var cellText = table.Cell(row, 0).Text;
if(cellText === ItemName)
{
foundRow = row;
break;
}
}
return foundRow;
}and then sometimes you access table data through an iterator like shown below
function Update_Table_()
{
// Comment:
// The table contents in the file has a '\n' at the end of each line and instead of the columns being separated
// by a comma, the columns are separated by '|' verticle line.
var table = Aliases.myApp.ATable;
var items = table.Items;
var totalRows = items.Count;
var contentForFile = "";
for(var row = 0 ; row < totalRows; row++)
{
var item = items.Item(row);
var description = item.Description_2.OleValue;
var stringVal = item.StringValue.OleValue;
var name = item.Suffix.OleValue;
var units = item.UnitsName.OleValue;
contentForFile = contentForFile +
`${name}|${stringVal}|${units}|${description}\n`;
}
aqFile.WriteToTextFile("C:\\Temp3\\DescriptionSortAscending.txt", contentForFile, aqFile.ctUTF8, true);
}