public final class ExcelPictureCollection extends ExcelDrawingCollectionImpl<ExcelPicture>
picture
s in the worksheet.
Following code demonstrates how to use images:
sheet.getPictures().add("Image.jpg", 10, 50, 100, 100, LengthUnit.PIXEL);
sheet.getPictures().add("Image.jpg", 10, 50, 100, 100, LengthUnit.PIXEL).getPosition().setMode(PositioningMode.MOVE);
sheet.getPictures().add("Image.jpg", "A2").getPosition().setMode(PositioningMode.MOVE_AND_SIZE);
sheet.getPictures().add("Image.jpg", 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.jpg");
// Picture format needs to be specified when adding from stream.
sheet.getPictures().add(pictureStream, ExcelPictureFormat.JPG, 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 |
---|---|
ExcelPicture |
add(InputStream pictureStream,
ExcelPictureFormat pictureFormat,
AnchorCell positionFrom,
AnchorCell positionTo)
Adds a new picture to the worksheet which moves and sizes with cells.
|
ExcelPicture |
add(InputStream pictureStream,
ExcelPictureFormat pictureFormat,
AnchorCell positionFrom,
double width,
double height,
LengthUnit unit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(InputStream pictureStream,
ExcelPictureFormat pictureFormat,
double left,
double top,
double width,
double height,
LengthUnit unit)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
|
ExcelPicture |
add(InputStream pictureStream,
ExcelPictureFormat pictureFormat,
String positionFromCell,
double width,
double height,
LengthUnit unit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(InputStream pictureStream,
ExcelPictureFormat pictureFormat,
String positionFromCell,
String positionToCell)
Adds a new picture to the worksheet which moves and sizes with cells.
|
ExcelPicture |
add(String picturePath,
AnchorCell positionFrom)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
AnchorCell positionFrom,
AnchorCell positionTo)
Adds a new picture to the worksheet which moves and sizes with cells.
|
ExcelPicture |
add(String picturePath,
AnchorCell positionFrom,
AnchorCell positionTo,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which moves and sizes with cells.
|
ExcelPicture |
add(String picturePath,
AnchorCell positionFrom,
double width,
double height,
LengthUnit unit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
AnchorCell positionFrom,
double width,
double height,
LengthUnit unit,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
AnchorCell positionFrom,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
double left,
double top,
double width,
double height,
LengthUnit unit)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
|
ExcelPicture |
add(String picturePath,
double left,
double top,
double width,
double height,
LengthUnit unit,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
|
ExcelPicture |
add(String picturePath,
double left,
double top,
LengthUnit unit)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
|
ExcelPicture |
add(String picturePath,
double left,
double top,
LengthUnit unit,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
|
ExcelPicture |
add(String picturePath,
String positionFromCell)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
String positionFromCell,
double width,
double height,
LengthUnit unit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
String positionFromCell,
double width,
double height,
LengthUnit unit,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
String positionFromCell,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which moves but doesn't size with cells.
|
ExcelPicture |
add(String picturePath,
String positionFromCell,
String positionToCell)
Adds a new picture to the worksheet which moves and sizes with cells.
|
ExcelPicture |
add(String picturePath,
String positionFromCell,
String positionToCell,
ExcelObjectSourceType sourceType)
Adds a new picture to the worksheet which moves and sizes with cells.
|
add, add, addAll, addAll, addCopy, clear, contains, containsAll, get, indexOf, isEmpty, iterator, move, remove, remove, removeAll, set, size, toArray, toArray
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addExcelDrawing, addExcelDrawing, getExcelDrawingCollectionWorksheet, getLastRowColumn, getObjectIterable
equals, hashCode, lastIndexOf, listIterator, listIterator, replaceAll, retainAll, sort, spliterator, subList
parallelStream, removeIf, stream
public ExcelPicture add(InputStream pictureStream, ExcelPictureFormat pictureFormat, AnchorCell positionFrom, AnchorCell positionTo) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE_AND_SIZE
.pictureStream
- The picture's stream.pictureFormat
- The picture's format.positionFrom
- The picture's position (top-left corner).positionTo
- The picture's end position (bottom-right corner).IOException
public ExcelPicture add(InputStream pictureStream, ExcelPictureFormat pictureFormat, AnchorCell positionFrom, double width, double height, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.pictureStream
- The picture's stream.pictureFormat
- The picture's format.positionFrom
- The picture's position.width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(InputStream pictureStream, ExcelPictureFormat pictureFormat, double left, double top, double width, double height, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.ExcelDrawingPosition.getMode()
getMode()} of a newly added picture will be PositioningMode.FREE_FLOATING
.pictureStream
- The picture's stream.pictureFormat
- The picture's format.left
- The distance of the left edge of the picture from the left edge of the worksheet.top
- The distance of the top edge of the picture from the top edge of the worksheet.width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(InputStream pictureStream, ExcelPictureFormat pictureFormat, String positionFromCell, double width, double height, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.pictureStream
- The picture's stream.pictureFormat
- The picture's format.positionFromCell
- The picture's position (for example, "A1").width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(InputStream pictureStream, ExcelPictureFormat pictureFormat, String positionFromCell, String positionToCell) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE_AND_SIZE
.pictureStream
- The picture's stream.pictureFormat
- The picture's format.positionFromCell
- The picture's position (top-left corner) (for example, "A1").positionToCell
- The picture's end position (bottom-right corner) (for example, "B2").IOException
public ExcelPicture add(String picturePath, AnchorCell positionFrom) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFrom
- The picture's position.IOException
public ExcelPicture add(String picturePath, AnchorCell positionFrom, AnchorCell positionTo) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE_AND_SIZE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFrom
- The picture's position (top-left corner).positionTo
- The picture's end position (bottom-right corner).IOException
public ExcelPicture add(String picturePath, AnchorCell positionFrom, AnchorCell positionTo, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE_AND_SIZE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFrom
- The picture's position (top-left corner).positionTo
- The picture's end position (bottom-right corner).sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, AnchorCell positionFrom, double width, double height, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFrom
- The picture's position.width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(String picturePath, AnchorCell positionFrom, double width, double height, LengthUnit unit, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFrom
- The picture's position.width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, AnchorCell positionFrom, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
This method uses ImageIO to determine picture's size.
picturePath
- The picture's path.positionFrom
- The picture's position.sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, double left, double top, double width, double height, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.FREE_FLOATING
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.left
- The distance of the left edge of the picture from the left edge of the worksheet.top
- The distance of the top edge of the picture from the top edge of the worksheet.width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(String picturePath, double left, double top, double width, double height, LengthUnit unit, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.FREE_FLOATING
.
picturePath parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.left
- The distance of the left edge of the picture from the left edge of the worksheet.top
- The distance of the top edge of the picture from the top edge of the worksheet.width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, double left, double top, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.FREE_FLOATING
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
This method uses ImageIO to determine picture's size.
picturePath
- The picture's path.left
- The distance of the left edge of the picture from the left edge of the worksheet.top
- The distance of the top edge of the picture from the top edge of the worksheet.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(String picturePath, double left, double top, LengthUnit unit, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.FREE_FLOATING
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
This method uses ImageIO to determine picture's size.
picturePath
- The picture's path.left
- The distance of the left edge of the picture from the left edge of the worksheet.top
- The distance of the top edge of the picture from the top edge of the worksheet.unit
- The length unit in which all length parameters are specified.sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, String positionFromCell) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFromCell
- The picture's position (for example, "A1").IOException
public ExcelPicture add(String picturePath, String positionFromCell, double width, double height, LengthUnit unit) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFromCell
- The picture's position (for example, "A1").width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.IOException
public ExcelPicture add(String picturePath, String positionFromCell, double width, double height, LengthUnit unit, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFromCell
- The picture's position (for example, "A1").width
- The picture's width.height
- The picture's height.unit
- The length unit in which all length parameters are specified.sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, String positionFromCell, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
This method uses ImageIO to determine picture's size.
picturePath
- The picture's path.positionFromCell
- The picture's position (for example, "A1").sourceType
- the picture's embedding or linking setting.IOException
public ExcelPicture add(String picturePath, String positionFromCell, String positionToCell) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE_AND_SIZE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFromCell
- The picture's position (top-left corner) (for example, "A1").positionToCell
- The picture's end position (bottom-right corner) (for example, "B2").IOException
public ExcelPicture add(String picturePath, String positionFromCell, String positionToCell, ExcelObjectSourceType sourceType) throws IOException
ExcelDrawing.getPosition()
.getMode()
of a newly added picture will be PositioningMode.MOVE_AND_SIZE
.
picturePath
parameter must contain supported extension (for example, ".png"), otherwise exception is thrown.
picturePath
- The picture's path.positionFromCell
- The picture's position (top-left corner) (for example, "A1").positionToCell
- The picture's end position (bottom-right corner) (for example, "B2").sourceType
- the picture's embedding or linking setting.IOException
© GemBox d.o.o. — All rights reserved.