Stephan Wunderlich napisał(a):
Hi Przemek
Is there an easy way to change properties of text table column,
i.e the back color of the column.
When i read this mailing list posts i found a post that suggests
to use text table rows, but for large tables this is not efficient.
The macro
sub Main
atable = ThisComponent.TextTables(0)
acolumn = getColumn(1,atable)
acolumn.BackColor=rgb(0,255,0)
end sub
function getColumn(col as Integer, table as Object) as Object
tablerows = table.rows.count-1
getColumn = table.getCellRangeByPosition(col,0,col,tablerows)
end function
will change the backgroundcolor of the second column in your first table.
Hope that helps
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Thanks for rapid reply!
I found the solution by my self in mean time. Here's the code in Java
public void setColumnProperty(Object xTable, int column, String
propertyName, Object propertyValue) throws Exception {
try {
//Check an instance of passed object
if(!(xTable instanceof XTextTable))
throw new InvalidObjectException("Passed xTable is not a
XTextTable object");
//Get cell range for whole text table
XCellRange xCellRange = (XCellRange)
UnoRuntime.queryInterface(XCellRange.class, (XTextTable)xTable );
//Get rows from the table, this is used to get the rows count.
XIndexAccess xRows = ((XTextTable)xTable).getRows();
//Get cell range for specified column
XCellRange xColumn =
xCellRange.getCellRangeByPosition(column, 0, column, xRows.getCount()-1);
//Get properties for the column
XPropertySet xColProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xColumn);
//And set the property ... ufff
xColProps.setPropertyValue(propertyName, propertyValue);
}
catch(com.sun.star.uno.Exception e) {
throw (RuntimeException) new RuntimeException("Can't set
column properties").initCause(e);
}
}
BTW, why there are no simple interface to use text table columns,
similar as text table rows?
Best regards
Przemek Kroliszewski
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]