// Getting the specified Notes database.
Database database = session.getDatabase( "", stringDatabase );
// Getting a collection of all documents from the database.
DocumentCollection documentCollection = database.getAllDocuments();
// Getting the first document from the database
Document document = documentCollection.getFirstDocument();
// Start to write to cells at this row.
int intRowToStart = 0;
// The current row.
int intRow = intRowToStart;
// The current column.
int intColumn = 0;
// Process all documents
while ( document != null ) {
// Getting the name of the stock.
String stringName = document.getItemValueString("Name");
// Inserting the name to a specified cell.
insertIntoCell(intColumn, intRow, stringName, xSpreadsheet, "");
// Getting the number of stocks.
double intNumber = document.getItemValueInteger( "Number" );
// Inserting the number of stocks to a specified cell.
insertIntoCell( intColumn + 1, intRow, String.valueOf(intNumber),
xSpreadsheet, "V" );
// Getting current share price.
double doubleSharePrice = document.getItemValueDouble("SharePrice");
// Inserting the current share price to a specified cell.
insertIntoCell(intColumn + 2, intRow,
String.valueOf(doubleSharePrice),
xSpreadsheet, "V");
// Inserting the total value.
insertIntoCell(intColumn + 3, intRow, "=B"
+ String.valueOf( intRow + 1 )
+ "*C" + String.valueOf(intRow + 1),
xSpreadsheet, "");
// Increasing the current row.
intRow++;
// Getting the next document from the collection.
document = documentCollection.getNextDocument();
}
// Summing all specific amounts.
insertIntoCell(intColumn + 3, intRow, "=sum(D"
+ String.valueOf( intRowToStart + 1 ) + ":D"