[]
        
(Showing Draft Content)

IGraphic

Interface IGraphic


public interface IGraphic
Represents the picture field included in the specified header or footer.

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);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the picture file path.
    double
    Returns a double value that represents the height, in points, of the object.
    boolean
    Gets whether the picture retains its original proportions when resized.
    double
    Gets the width, in points, of the object.
    void
    Sets the picture file path.
    void
    Sets the picture data using the specified InputStream.
    void
    setHeight(double value)
    Sets a double value that represents the height, in points, of the object.
    void
    setLockAspectRatio(boolean value)
    Sets whether the picture retains its original proportions when resized.
    void
    setWidth(double value)
    Sets the width, in points, of the object.
  • Method Details

    • getFilename

      String getFilename()
      Gets the picture file path.

      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();
       
      Returns:
      The picture file path.
    • setFilename

      void setFilename(String value) throws FileNotFoundException
      Sets the picture file path.

      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);
       }
       
      Parameters:
      value - The picture file path.
      Throws:
      FileNotFoundException - if the specified file cannot be found.
    • setGraphicStream

      void setGraphicStream(InputStream stream, ImageType imageType)
      Sets the picture data using the specified 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);
       }
       
      Parameters:
      stream - The input stream that provides the image data.
      imageType - The type of the image data in the stream.
    • getHeight

      double getHeight()
      Returns a 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();
       
      Returns:
      A double value that represents the height of the object, in points.
    • setHeight

      void setHeight(double value)
      Sets a 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);
       
      Parameters:
      value - A double value that represents the height of the object, in points.
    • getWidth

      double getWidth()
      Gets the width, in points, of the object.

      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();
       
      Returns:
      The width of the object, in points.
    • setWidth

      void setWidth(double value)
      Sets the width, in points, of the object.

      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);
       
      Parameters:
      value - The width of the object, in points.
    • getLockAspectRatio

      boolean getLockAspectRatio()
      Gets whether the picture retains its original proportions when resized.

      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();
       
      Returns:
      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.
    • setLockAspectRatio

      void setLockAspectRatio(boolean value)
      Sets whether the picture retains its original proportions when resized.

      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);
       
      Parameters:
      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.