log.println( "Creating a test environment" );
log.println("getting sheets");
XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
XIndexAccess oIndexAccess = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
XSpreadsheet oSheet = null;
Object oChangeCell = null;
Object oCheckCell = null;
try {
oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),oIndexAccess.getByIndex(0));
oChangeCell = oSheet.getCellByPosition(1, 5);
oCheckCell = oSheet.getCellByPosition(
sCellAddress.Column, sCellAddress.Row + 3);
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException( "Couldn't get a spreadsheet", e);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException( "Couldn't get a spreadsheet", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException( "Couldn't get a spreadsheet", e);
}
log.println("Getting sheet - " + (oSheet == null ? "FAILED" : "OK"));
try {
log.println("Filing a table");
for (int i = 1; i < 6; i++) {
oSheet.getCellByPosition(0, i).setFormula("Row" + i);
oSheet.getCellByPosition(i, 0).setFormula("Col" + i);
}
for (int i = 1; i < 6; i++)
for (int j = 1; j < 6; j++) {
oSheet.getCellByPosition(i, j).setValue(2.5 * j + i);
}
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't fill some cells", e);
}