throw new IOException("Unable to load styles - " + e.toString());
}
// Load individual sheets
for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
PackagePart part = getPackagePart(ctSheet);
if (part == null) {
log.log(POILogger.WARN, "Sheet with name " + ctSheet.getName() + " and r:id " + ctSheet.getId()+ " was defined, but didn't exist in package, skipping");
continue;
}
// Load child streams of the sheet
ArrayList<? extends XSSFModel> childModels;
CommentsSource comments = null;
ArrayList<Drawing> drawings;
ArrayList<Control> controls;
try {
// Get the comments for the sheet, if there are any
childModels = XSSFRelation.SHEET_COMMENTS.loadAll(part);
if(childModels.size() > 0) {
comments = (CommentsSource)childModels.get(0);
}
// Get the drawings for the sheet, if there are any
drawings = (ArrayList<Drawing>)XSSFRelation.VML_DRAWINGS.loadAll(part);
// Get the activeX controls for the sheet, if there are any
controls = (ArrayList<Control>)XSSFRelation.ACTIVEX_CONTROLS.loadAll(part);
} catch(Exception e) {
throw new RuntimeException("Unable to construct child part",e);
}
// Now create the sheet
WorksheetDocument worksheetDoc = WorksheetDocument.Factory.parse(part.getInputStream());
XSSFSheet sheet = new XSSFSheet(ctSheet, worksheetDoc.getWorksheet(), this, comments, drawings, controls);
this.sheets.add(sheet);
// Process external hyperlinks for the sheet,
// if there are any
PackageRelationshipCollection hyperlinkRels =
part.getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation());
sheet.initHyperlinks(hyperlinkRels);
// Get the embeddings for the workbook
for(PackageRelationship rel : part.getRelationshipsByType(XSSFRelation.OLEEMBEDDINGS.getRelation()))
embedds.add(getTargetPart(rel)); // TODO: Add this reference to each sheet as well
for(PackageRelationship rel : part.getRelationshipsByType(XSSFRelation.PACKEMBEDDINGS.getRelation()))
embedds.add(getTargetPart(rel));
}
} catch (XmlException e) {
throw new IOException(e.toString());
} catch (InvalidFormatException e) {