public final class ExcelPicture extends ExcelDrawing
Following code demonstrates how to use images:
sheet.getPictures().add("Image.bmp", 10, 50, 100, 100, LengthUnit.PIXEL);
sheet.getPictures().add("Image.bmp", 10, 50, 100, 100, LengthUnit.PIXEL).getPosition().setMode(PositioningMode.MOVE);
sheet.getPictures().add("Image.bmp", "A2").getPosition().setMode(PositioningMode.MOVE_AND_SIZE);
sheet.getPictures().add("Image.bmp", new AnchorCell(sheet.getColumn(0), sheet.getRow(1), 10, 10, LengthUnit.PIXEL), new AnchorCell(sheet.getColumn(3), sheet.getRow(3), false));
// NOTE: pictureStream must not be disposed while it is still used by ExcelFile or exception will be thrown.
FileInputStream pictureStream = new FileInputStream("Image.bmp");
// Picture format needs to be specified when adding from stream.
sheet.getPictures().add(pictureStream, ExcelPictureFormat.BMP, new AnchorCell(sheet.getColumn(0), sheet.getRow(1), 10, 10, LengthUnit.PIXEL), new AnchorCell(sheet.getColumn(3), sheet.getRow(3), false));
ExcelWorksheet.getPictures()
Modifier and Type | Method and Description |
---|---|
void |
delete()
Removes this
ExcelPicture instance from the worksheet. |
ExcelPictureFormat |
getPictureFormat()
Gets the picture format.
|
InputStream |
getPictureStream()
Gets the picture stream.
|
com.gembox.spreadsheet.internal.objects.ExcelObjectSource |
getSource() |
Optional<SpreadsheetColor> |
getTransparentColor() |
void |
setTransparentColor(Optional<SpreadsheetColor> transparentColor) |
Image |
toImage()
Converts this
ExcelPicture instance to a new Image instance. |
String |
toString()
Returns a
String that represents this ExcelPicture instance. |
getHyperlink, getMetadata, getPosition, setHyperlink
public void delete()
ExcelPicture
instance from the worksheet.public ExcelPictureFormat getPictureFormat()
public InputStream getPictureStream() throws IOException
IOException
public com.gembox.spreadsheet.internal.objects.ExcelObjectSource getSource()
public Optional<SpreadsheetColor> getTransparentColor()
public void setTransparentColor(Optional<SpreadsheetColor> transparentColor)
public Image toImage() throws IOException
ExcelPicture
instance to a new Image
instance.Image
instance created from this ExcelPicture
instance.IOException
public String toString()
String
that represents this ExcelPicture
instance.
This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).
toString
in class Object
String
that represents this ExcelPicture
instance.© GemBox Ltd. — All rights reserved.