[]
Use this interface to configure the image that appears in a worksheet header or footer, including the source image, dimensions, and aspect ratio behavior.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try (InputStream stream = createSampleImageStream()) {
graphic.setGraphicStream(stream, ImageType.PNG);
} catch (IOException e) {
throw new IllegalStateException("Unable to set header graphic stream", e);
}
graphic.setLockAspectRatio(false);
graphic.setWidth(120);
graphic.setHeight(40);
doubledouble value that represents the height, in points, of the object.booleandoublegetWidth()voidsetFilename(String value) voidsetGraphicStream(InputStream stream,
ImageType imageType) InputStream.voidsetHeight(double value) double value that represents the height, in points, of the object.voidsetLockAspectRatio(boolean value) voidsetWidth(double value) Use this method to retrieve the file path associated with the picture field represented by this IGraphic.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
graphic.setFilename(imagePath);
} catch (FileNotFoundException e) {
throw new IllegalStateException("Unable to set header graphic filename", e);
}
String filename = graphic.getFilename();
Use this method to update the file path associated with the picture field represented by this IGraphic.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
graphic.setFilename(imagePath);
} catch (FileNotFoundException e) {
throw new IllegalStateException("Unable to set header graphic filename", e);
}
value - The picture file path.FileNotFoundException - if the specified file cannot be found.InputStream. Use this method to assign image data to the picture field represented by this IGraphic. The imageType parameter specifies the format of the image data provided by the stream.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try (InputStream stream = createSampleImageStream()) {
graphic.setGraphicStream(stream, ImageType.PNG);
} catch (Exception e) {
throw new IllegalStateException("Unable to set header graphic stream", e);
}
stream - The input stream that provides the image data.imageType - The type of the image data in the stream.double value that represents the height, in points, of the object.Use this method to retrieve the current height of the picture field represented by this IGraphic.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
graphic.setFilename(imagePath);
} catch (FileNotFoundException e) {
throw new IllegalStateException("Unable to set header graphic filename", e);
}
double height = graphic.getHeight();
double value that represents the height of the object, in points.double value that represents the height, in points, of the object.Use this method to update the current height of the picture field represented by this IGraphic.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
graphic.setFilename(imagePath);
} catch (FileNotFoundException e) {
throw new IllegalStateException("Unable to set header graphic filename", e);
}
graphic.setHeight(100.0);
value - A double value that represents the height of the object, in points.Returns a double value that represents the width, in points, of the object.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
graphic.setFilename(imagePath);
} catch (FileNotFoundException e) {
throw new IllegalStateException("Unable to set header graphic filename", e);
}
double width = graphic.getWidth();
Use this method to update the width, in points, of the picture field represented by this IGraphic.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
graphic.setFilename(imagePath);
} catch (FileNotFoundException e) {
throw new IllegalStateException("Unable to set header graphic filename", e);
}
graphic.setWidth(100.0);
value - The width of the object, in points.Returns whether the picture retains its original proportions when you resize it.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try (InputStream stream = createSampleImageStream()) {
graphic.setGraphicStream(stream, ImageType.PNG);
} catch (IOException e) {
throw new IllegalStateException("Unable to set header graphic stream", e);
}
graphic.setLockAspectRatio(true);
boolean lockAspectRatio = graphic.getLockAspectRatio();
true if the picture retains its original proportions when you resize it; false if you can change the height and width of the picture independently of one another when you resize it.Sets whether the picture retains its original proportions when you resize it.
IGraphic graphic = worksheet.getPageSetup().getCenterHeaderPicture();
try (InputStream stream = createSampleImageStream()) {
graphic.setGraphicStream(stream, ImageType.PNG);
} catch (IOException e) {
throw new IllegalStateException("Unable to set header graphic stream", e);
}
graphic.setLockAspectRatio(true);
value - true if the picture retains its original proportions when you resize it; false if you can change the height and width of the picture independently of one another when you resize it.