[]
Iterable<IBackgroundPicture>This interface provides access to the IBackgroundPicture objects associated with a sheet, including retrieving pictures by index or name and obtaining the total number of pictures in the collection.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
try (InputStream stream = createSampleImageStream()) {
IBackgroundPicture createdPicture = backgroundPictures.addPicture(stream, ImageType.PNG, 12, 18, 120, 80);
createdPicture.setName("Watermark");
}
int count = backgroundPictures.getCount();
IBackgroundPicture picture = backgroundPictures.get(0);
IBackgroundPicture namedPicture = backgroundPictures.get("Watermark");
addPicture(InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) IBackgroundPicture object.addPicture(String filename,
double left,
double top,
double width,
double height) IBackgroundPicture object that represents the new background picture.addPictureInPixel(InputStream stream,
ImageType type,
double left,
double top,
double width,
double height) IBackgroundPicture object that represents the new background picture.addPictureInPixel(String filename,
double left,
double top,
double width,
double height) IBackgroundPicture object that represents the new background picture.get(int index) intgetCount()forEach, iterator, spliteratorUse the index parameter to retrieve a background picture by its position in the IBackgroundPictures collection.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
int count = backgroundPictures.getCount();
if (count > 0) {
IBackgroundPicture picture = backgroundPictures.get(0);
}
index - The zero-based index of the background picture in the collection.IBackgroundPicture at the specified index.Use this method to retrieve an IBackgroundPicture from the current IBackgroundPictures collection by its name.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
try (InputStream stream = createSampleImageStream()) {
backgroundPictures.addPicture(stream, ImageType.PNG, 12, 18, 120, 80).setName("Logo");
}
IBackgroundPicture picture = backgroundPictures.get("Logo");
name - The String name of the object to retrieve.IBackgroundPicture object with the specified name.Gets the number of IBackgroundPicture objects in this background picture collection for the worksheet.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
backgroundPictures.addPicture(imagePath, 12, 18, 160, 90);
} catch (IOException e) {
throw new IllegalStateException("Unable to add sample background picture from file", e);
}
int count = backgroundPictures.getCount();
IBackgroundPicture object that represents the new background picture.The picture is positioned and sized by the destination rectangle specified in points relative to the upper-left corner of the document.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IBackgroundPicture picture = backgroundPictures.addPicture(imagePath, 12, 18, 160, 90);
} catch (IOException e) {
throw new IllegalStateException("Unable to add sample background picture from file", e);
}
filename - The file from which the background picture is created.left - The position, in points, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the destination rectangle relative to the top of the document.width - The width of the destination rectangle, in points.height - The height of the destination rectangle, in points.IBackgroundPicture object that represents the new background picture.IOException - if the specified file cannot be read.IBackgroundPicture object.Use this method to add a background picture at the specified position and size in points. The left and top parameters specify the upper-left corner of the destination rectangle relative to the upper-left corner of the document.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
IBackgroundPicture picture = null;
try (InputStream stream = createSampleImageStream()) {
picture = backgroundPictures.addPicture(stream, ImageType.PNG, 12, 18, 120, 80);
picture.setBackgroundImageLayout(ImageLayout.Center);
} catch (IOException e) {
throw new IllegalStateException("Unable to add sample background picture from stream", e);
}
stream - The stream from which the background picture is created.type - Specifies the image type of the stream.left - The position, in points, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document.top - The position, in points, of the upper-left corner of the destination rectangle relative to the top of the document.width - The width of the destination rectangle, in points.height - The height of the destination rectangle, in points.IBackgroundPicture object.IOException - if an I/O error occurs while reading the image stream.IBackgroundPicture object that represents the new background picture.The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
IBackgroundPicture picture = backgroundPictures.addPictureInPixel(imagePath, 12, 18, 160, 90);
} catch (IOException e) {
throw new IllegalStateException("Unable to add sample background picture in pixel from file", e);
}
filename - The file from which the background picture is created.left - The position, in pixels, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document.top - The position, in pixels, of the upper-left corner of the destination rectangle relative to the top of the document.width - The width of the destination rectangle, in pixels.height - The height of the destination rectangle, in pixels.IBackgroundPicture object that represents the new background picture.IOException - if the specified file cannot be read.IBackgroundPicture object that represents the new background picture. The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.
IBackgroundPictures backgroundPictures = worksheet.getBackgroundPictures();
IBackgroundPicture picture = null;
try (InputStream stream = createSampleImageStream()) {
picture = backgroundPictures.addPictureInPixel(stream, ImageType.PNG, 12, 18, 160, 90);
} catch (IOException e) {
throw new IllegalStateException("Unable to add sample background picture in pixel from stream", e);
}
stream - The stream from which the background picture is created.type - Specifies the type of picture to create.left - The position, in pixels, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document.top - The position, in pixels, of the upper-left corner of the destination rectangle relative to the top of the document.width - The width of the destination rectangle, in pixels.height - The height of the destination rectangle, in pixels.IBackgroundPicture object that represents the new background picture.IOException - if an I/O error occurs while reading the image stream.