/**
* Maps relId and the corresponding PackagePart
*/
- private Map<String, PackagePart> sheetMap;
+ private final Map<String, PackagePart> sheetMap;
/**
* Current CTSheet bean
* We can't rely on the Ooxml4J's relationship iterator because it returns objects in physical order,
* i.e. as they are stored in the underlying package
*/
- private Iterator<CTSheet> sheetIterator;
+ private final Iterator<CTSheet> sheetIterator;
/**
* Construct a new SheetIterator
try {
//step 1. Map sheet's relationship Id and the corresponding PackagePart
sheetMap = new HashMap<String, PackagePart>();
+ OPCPackage pkg = wb.getPackage();
+ String REL_WORKSHEET = XSSFRelation.WORKSHEET.getRelation();
+ String REL_CHARTSHEET = XSSFRelation.CHARTSHEET.getRelation();
for(PackageRelationship rel : wb.getRelationships()){
- if(rel.getRelationshipType().equals(XSSFRelation.WORKSHEET.getRelation()) ||
- rel.getRelationshipType().equals(XSSFRelation.CHARTSHEET.getRelation())){
+ String relType = rel.getRelationshipType();
+ if (relType.equals(REL_WORKSHEET) || relType.equals(REL_CHARTSHEET)) {
PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
- sheetMap.put(rel.getId(), wb.getPackage().getPart(relName));
+ sheetMap.put(rel.getId(), pkg.getPart(relName));
}
}
//step 2. Read array of CTSheet elements, wrap it in a ArayList and construct an iterator
*
* @return <tt>true</tt> if the iterator has more elements.
*/
+ @Override
public boolean hasNext() {
return sheetIterator.hasNext();
}
*
* @return input stream of the next sheet in the iteration
*/
+ @Override
public InputStream next() {
ctSheet = sheetIterator.next();
/**
* We're read only, so remove isn't supported
*/
+ @Override
public void remove() {
throw new IllegalStateException("Not supported");
}