 | OO-Snippets: cell/columns attribCommons| Keywords | cell attributes, backgroundcolor, optimal width |
|---|
| Language | Java |
|---|
| Application | Calc |
|---|
| Authors | Tom Schindl (initial)
|
|---|
| Supported Versions | |
|---|
| Supported OS | |
|---|
| Question |
How can I modify cell-attributes
e.g. set the background-color, set the width to optimal value
|
|---|
| Answer | |
|---|
try {
XCellRange range = xSpreadSheet_.getCellRangeByPosition(0,1,17,1);
XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, range);
xPropSet.setPropertyValue("CharWeight", new Double(FontWeight.BOLD));
xPropSet.setPropertyValue("CellBackColor", new Integer(0xAAAAAA));
xPropSet.setPropertyValue("HoriJustify", CellHoriJustify.LEFT);
XColumnRowRange xColRange = (XColumnRowRange)UnoRuntime.queryInterface(XColumnRowRange.class,range);
XEnumerationAccess xEnumAccess = (XEnumerationAccess)UnoRuntime.queryInterface(XEnumerationAccess.class,xColRange.getColumns());
XEnumeration xEnum = xEnumAccess.createEnumeration();
Object tableColumnService;
while( xEnum.hasMoreElements() ) {
tableColumnService = xEnum.nextElement();
xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, tableColumnService);
xPropSet.setPropertyValue("OptimalWidth",new Boolean(true));
}
} catch( Exception e) {
e.printStackTrace();
}
|
Changelog| Date | User | Modification |
|---|
| 2004-11-18 | tomsontom | Initial version |
|