XSpreadsheets xSheets = null;
xSheets = (XSpreadsheets) xSheetdocument.getSheets();
// the Action Interface provides methods to hide actions,
// like inserting data, on a sheet, that increase the performance
XActionLockable xActionInterface = null;
xActionInterface = (XActionLockable) UnoRuntime.queryInterface(
XActionLockable.class, xSheetdocument );
// lock all actions
xActionInterface.addActionLock();
com.sun.star.sheet.XSpreadsheet xSheet = null;
try {
// get via the index access the first sheet
XIndexAccess xElements = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xSheets );
// specify the first sheet from the spreadsheet
xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
XSpreadsheet.class, xElements.getByIndex( 0 ));
}
catch( Exception e) {
e.printStackTrace(System.err);
}
// get the interface to apply and create new numberformats
XNumberFormatsSupplier xNumberFormatSupplier = null;
xNumberFormatSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(
XNumberFormatsSupplier.class, xSheetdocument );
XNumberFormats xNumberFormats = null;
xNumberFormats = xNumberFormatSupplier.getNumberFormats();
// insert some example data in a sheet
createExampleData( xSheet, xNumberFormats );
System.out.println( "Insert example data and use the number format with the currency 'DM'" );
// Change the currency from the cells from DM to Euro
Convert( xSheet, xNumberFormats, "DM", "EUR", 1.95583f );
System.out.println( "Change the number format to EUR and divide the values with the factor 1.95583" );
// remove all locks, the user see all changes
xActionInterface.removeActionLock();
System.out.println("done");
System.exit(0);
}