 | OO-Snippets: How to assign an auto-format to columnsCommons| Keywords | auto-format |
|---|
| Language | Java |
|---|
| Application | Calc |
|---|
| Authors | Tom Schindl (initial)
|
|---|
| Supported Versions | 1.1.4 1.1.x |
|---|
| Supported OS | All |
|---|
| Question |
How can I assign an autoformat to cells
|
|---|
| Answer | You need to retrieve a cell-tange and retrieve its com.sun.star.table.XAutoFormattable interface |
|---|
Object sheets = xSpreadsheetDocument.getSheets();
XIndexAccess xIndexedSheets = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, sheets);
Object sheet = xIndexedSheets.getByIndex(0);
XSpreadsheet xSpreadSheet_ = (XSpreadsheet) UnoRuntime.queryInterface(XSpreadsheet.class, sheet);
XCellRange rangeToFormat = xSpreadSheet.getCellRangeByPosition(0,0,9,9)
XAutoFormattable xAutoForm = (XAutoFormattable)UnoRuntime.queryInterface(XAutoFormattable.class, rangeToFormat);
try {
xAutoForm.autoFormat("OEUSH-Abbucher-Bericht");
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
|
Changelog| Date | User | Modification |
|---|
| 2005-03-10 | tomsontom | Initial version |
|