Enumeration e = cd.getDocumentEnumeration();
while(e.hasMoreElements()) {
palmDoc = (PalmDocument) e.nextElement();
// Convert PDB to WorkBook/WorkSheet format
PalmDB pdb = palmDoc.getPdb();
// This will be done at least once
String sheetName = worksheetNames[j];
// Get number of records in the pdb
int numRecords = pdb.getRecordCount();
// sheetName does not contain the WorkBook name, but we need the
// full name.
String fullSheetName = new String(wb.getWorkbookName() + "-" + sheetName);
// Create a new (empty) WorkSheet
ws = new Worksheet();
// Initialize the WorkSheet
ws.initWorksheet(fullSheetName, numRecords);
// Loop over the number of records in the PDB
for (int i = 0; i < numRecords; i++) {
// Read record i from the PDB
Record rec = pdb.getRecord(i);
byte cBytes[] = rec.getBytes();
// Create an InputStream
ByteArrayInputStream bis = new ByteArrayInputStream(cBytes);