public class XSSFPictureData extends POIXMLDocumentPart implements PictureData
POIXMLDocumentPart.RelationPart
Modifier and Type | Field and Description |
---|---|
protected static POIXMLRelation[] |
RELATIONS
Relationships for each known picture type
|
Modifier | Constructor and Description |
---|---|
protected |
XSSFPictureData()
Create a new XSSFPictureData node
|
protected |
XSSFPictureData(PackagePart part)
Construct XSSFPictureData from a package part
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getData()
Gets the picture data as a byte array.
|
static int |
getMaxImageSize() |
java.lang.String |
getMimeType()
Returns the mime type for the image
|
int |
getPictureType() |
protected void |
prepareForCommit()
*PictureData objects store the actual content in the part directly without keeping a
copy like all others therefore we need to handle them differently.
|
static void |
setMaxImageSize(int length) |
java.lang.String |
suggestFileExtension()
Suggests a file extension for this image.
|
_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
protected static final POIXMLRelation[] RELATIONS
protected XSSFPictureData()
XSSFWorkbook.addPicture(byte[], int)
protected XSSFPictureData(PackagePart part)
part
- the package part holding the drawing data,public static void setMaxImageSize(int length)
length
- the max image size allowed for XSSF picturespublic static int getMaxImageSize()
public byte[] getData()
Note, that this call might be expensive since all the picture data is copied into a temporary byte array.
You can grab the picture data directly from the underlying package part as follows:
InputStream is = getPackagePart().getInputStream();
getData
in interface PictureData
public java.lang.String suggestFileExtension()
PictureData
suggestFileExtension
in interface PictureData
.
. Never null
, but will be empty if the extension
is unknown or if the file backing these data does not have an extension.public int getPictureType()
getPictureType
in interface PictureData
0
if unknown image typeWorkbook.PICTURE_TYPE_DIB
,
Workbook.PICTURE_TYPE_EMF
,
Workbook.PICTURE_TYPE_JPEG
,
Workbook.PICTURE_TYPE_PICT
,
Workbook.PICTURE_TYPE_PNG
,
Workbook.PICTURE_TYPE_WMF
public java.lang.String getMimeType()
PictureData
getMimeType
in interface PictureData
protected void prepareForCommit()
prepareForCommit
in class POIXMLDocumentPart
Copyright 2022 The Apache Software Foundation or its licensors, as applicable.