-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting XSSFPictures via the sheet DrawingPatriarch does not properly expose the PIctureData #180
Comments
Can you provide a reproducible test case? |
This method returns null. so, I can't get the data of the image, but I can get anchor and shapeName /**
* Return picture data for this shape
*
* @return picture data for this shape
*/
@Override
public XSSFPictureData getPictureData() {
String blipId = ctPicture.getBlipFill().getBlip().getEmbed();
return (XSSFPictureData)getDrawing().getRelationById(blipId);
} excel template I used for testing |
What I mean by a reproducible test case is providing an xlsx file that shows the issue and the code you are using. There are a couple of test cases in this project that show this code works for at least some xlsx files. |
example: public static void main(String[] args) throws FileNotFoundException {
InputStream is = new FileInputStream("E:\\IdeaProjects\\demo\\test.xlsx");
Workbook workbook = StreamingReader.builder()
.rowCacheSize(100)
.bufferSize(4096)
.setReadShapes(true)
.open(is);
Sheet sheet = workbook.getSheetAt(0);
Drawing<?> shapes = sheet.getDrawingPatriarch();
for (Shape shape : shapes) {
System.out.println();
XSSFPicture picture = (XSSFPicture) shape;
System.out.println("picture data => " + picture.getPictureData()); // is null
System.out.println(picture.getClientAnchor().getRow1() + "-" + picture.getClientAnchor().getCol1()); // available
}
} file: |
This approach has not been a priority. You must note that excel-streaming-reader does not offer 100% support for everything you can do with POI's XSSF code base. It may be possible to get it to work but it doesn't work at the moment. This is the approach that has been prioritised and there are tests to show it working
So you can get the picture data that way. You can use the code that you are using to get the anchor details. At some stage in the future, I can look at seeing if the XSSFPictures retrieved via the DrawingPatriarch can be made to properly expose the picture data. If you want to investigate the issue and submit a PR, I will take a look at it. |
As shown in the picture below
workbook.getAllPictures gets the image data, but it doesn't seem to match a cell. So I went through the sheet's getDrawingPatriarch to get the image, but I couldn't read the image
The text was updated successfully, but these errors were encountered: