Ah, good point. If you use HTML to color the numbers, the cell contents becomes Strings instead of Numbers, and it becomes awkward to do programmatic calculations of these numbers. You have 2 options here:
One is to do as you suggested - have your numeric calculation code try to parse out the digits in the HTML strings and use those. I don’t recommend this - very fragile.
Option two is better. The Table component has the ability to hide certain columns from view. It is important to know that these hidden columns can still be accessed programmatically, however. The idea here is to select the HTML formatted data, and then the raw data (use a different column name using the SQL “AS” clause), and hide the raw data.
Lets say your data looked like this:
(Columns)Type, Vessel, Value, RawValue
(Ex. Data) “A”, 10, “…2.1”, 2.1
Now, tell the table to hide the “RawValue” column.
The following code will calculate the average of the selected RawValues:
[code]#This line will vary depending on your window
table = event.source.parent.getComponent(“Table”)
selectedRows = table.getSelectedRows()
total = 0
for rowNum in selectedRows:
value = table.data.getValueAt(rowNum, 3) # 3 is the column index of “RawValue”
total += value
average = total / len(selectedRows)
print "Average is: ", average