auto-format Tom Schindl How can I assign an autoformat to cells

You need to retrieve a cell-tange and retrieve its {@link com.sun.star.table.XAutoFormattable} interface

/* -------------------------------------------------------- * We assume that you got somewhere an xSpreadsheetDocument * -------------------------------------------------------- */ 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); // get a range with 10x10 range XCellRange rangeToFormat = xSpreadSheet.getCellRangeByPosition(0,0,9,9) // now retrieve the {@see com.sun.star.table.XAutoFormattable}-Interface XAutoFormattable xAutoForm = (XAutoFormattable)UnoRuntime.queryInterface(XAutoFormattable.class, rangeToFormat); /* * Although this is an runtime exception we are catching it because * if the format is missing because any reason don't want to stop * the processing */ try { xAutoForm.autoFormat("OEUSH-Abbucher-Bericht"); } catch (IllegalArgumentException e) { e.printStackTrace(); }
Initial version