/** This class creates an OpenOffice.org Calc spreadsheet document and fills it *withexistingvaluesofdocumentsfromaLotusNotesdatabase.
*/ publicclass NotesAccess implements Runnable {
/** Host server of the Domino Directory.
*/ static String stringHost = "";
/** User in the host's Domino Directory.
*/ static String stringUser = "";
/** Password for the user in the host's Domino Directory.
*/ static String stringPassword = "";
/** Database with documents to get data from.
*/ static String stringDatabase = "";
/** Reading the arguments and constructing the thread. *@paramargsHoldingvaluesforthehost,user,andthepasswordoftheuser.
*/ publicstaticvoid main( String args[] ) { Threadthread;
try {
java.io.File sourceFile = new java.io.File(args[ 3 ].trim());
stringDatabase = sourceFile.getCanonicalPath();
} catch (java.io.IOException e) {
System.out.println("Error: Please check the name or path to your database file.");
e.printStackTrace();
System.exit( 1 );
}
if ( stringHost.equals( "" ) ) { // Initializing.
NotesAccess notesaccess = new NotesAccess();
// Allowing only local calls to the Domino classes. thread = new NotesThread( notesaccess );
} else { // Extracting the host, user, and password.
NotesAccess notesaccess = new NotesAccess();
// Allowing remote calls to the Domino classes. thread = newThread( notesaccess );
}
// Starting the thread. thread.start();
}
/** Reading all documents from the given database and writing the data to *anOpenOffice.orgCalcspreadsheetdocument.
*/ publicvoid run() { try { // get the remote office component context
XComponentContext xContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
/* A desktop environment contains tasks with one or more framesinwhichcomponentscanbeloaded.Desktopisthe environmentforcomponentswhichcaninstantiatewithin
frames. */
XComponentLoader xLoader = UnoRuntime.queryInterface(XComponentLoader.class,
xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop", xContext));
// Load a Writer document, which will be automatically displayed
XComponent xComponent = xLoader.loadComponentFromURL( "private:factory/scalc", "_blank", 0, new PropertyValue[0] );
// Querying for the interface XSpreadsheetDocument
XSpreadsheetDocument xSpreadsheetDoc =
UnoRuntime.queryInterface(
XSpreadsheetDocument.class, xComponent);
// Getting all sheets from the spreadsheet document.
XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets() ;
// Querying for the interface XIndexAccess.
XIndexAccess xIndexAccess = UnoRuntime.queryInterface(
XIndexAccess.class, xSpreadsheets);
// Getting the first spreadsheet.
XSpreadsheet xSpreadsheet = UnoRuntime.queryInterface(
XSpreadsheet.class, xIndexAccess.getByIndex(0));
Session session; if ( !stringHost.equals( "" ) ) { // Creating a Notes session for remote calls to the Domino classes.
session = NotesFactory.createSession(stringHost, stringUser,
stringPassword);
} else { // Creating a Notes session for only local calls to the // Domino classes.
session = NotesFactory.createSession();
}
/** Inserting a value or formula to a cell defined by the row and column. *@paramintCellXRow. *@paramintCellYColumn. *@paramstringValueThisvaluewillbewrittentothecell. *@paramxSpreadsheetWritethevaluetothecellsofthisspreadsheet. *@paramstringFlagIfthisstringcontains"V",thevaluewillbewritten, *otherwisetheformula.
*/ publicstaticvoid insertIntoCell(int intCellX, int intCellY,
String stringValue,
XSpreadsheet xSpreadsheet,
String stringFlag)
{
XCell xCell = null;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.