pjfanning opened a new pull request, #1382: URL: https://github.com/apache/poi/pull/1382
Lets event-model readers that need random access to sheets, such as [excel-streaming-reader](https://github.com/pjfanning/excel-streaming-reader), reuse `XSSFReader` instead of copying the `SheetIterator` internals. Changes (all additive): - `XSSFRelation.getStrictRelation()`: the Strict OOXML relationship type (`http://purl.oclc.org/ooxml/officeDocument/relationships/...`) for `officeDocument` relations, or null for Microsoft extensions. - `SheetIterator` now also recognises Strict OOXML worksheet and chartsheet relationships. Before this, `new XSSFReader(pkg, true).getSheetIterator().next()` on a strict file failed with "Failed to find sheet package". - `SheetIterator.getSheetRefs()` and `SheetIterator.getSheetPart(XSSFSheetRef)`: random access, independent of the iterator position. They live on `SheetIterator` so that `XSSFBReader`'s binary sheet-ref parsing is used for `.xlsb` files. - `XSSFReader.getSheetPart(String relId)`. `getSheet(relId)` now uses it. - `static XSSFReader.getSheetCommentsPart(PackagePart, boolean allowStrictOoxmlFiles)` and `getSheetDrawingParts(PackagePart, boolean)`. `SheetIterator.getSheetComments()` and `getShapes()` delegate to these with `false`, so their behaviour is unchanged. The comments and drawing lookups only follow the strict relationships when asked. `CommentsTable` and `XSSFDrawing` can't parse Strict OOXML namespaces, so following them by default would turn today's null/empty results for strict files into parse warnings. Callers that convert strict parts (as excel-streaming-reader does) can opt in. New tests in `TestXSSFReader` cover iterating a strict file, random access, and the strict fallback for comments and drawings (by retyping the relationship in an in-memory package, since test-data has no strict file with comments or drawings). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
