[]
        
(Showing Draft Content)

ImageSaveOptions

Class ImageSaveOptions

java.lang.Object
com.grapecity.documents.excel.ImageSaveOptions

public class ImageSaveOptions extends Object
Represents options for exporting a worksheet, range, or shape to an image file.

Use this class to control image export settings such as scale, resolution, background color, gridline display, row and column headings, drawing objects, black-and-white output, and whether automatically merged cells are included.


 worksheet.getRange("A1:B2").setValue(new Object[][] {
     {"Name", "Value"},
     {"North", 120}
 });
 ImageSaveOptions options = new ImageSaveOptions();
 options.setBackgroundColor(Color.FromArgb(255, 0, 0));
 options.setShowGridlines(true);
 ByteArrayOutputStream stream = new ByteArrayOutputStream();
 worksheet.toImage(stream, ImageType.PNG, options);
 
  • Constructor Details

    • ImageSaveOptions

      public ImageSaveOptions()
  • Method Details

    • getBackgroundColor

      public Color getBackgroundColor()
      Gets the background color of the exported image.

      This property specifies the color used when exporting a worksheet, range, or shape to an image. If no background color has been assigned, this method returns null.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setBackgroundColor(Color.FromArgb(255, 0, 0));
       Color backgroundColor = options.getBackgroundColor();
       
      Returns:
      The background color of the exported image. Returns null if no background color has been set.
    • setBackgroundColor

      public void setBackgroundColor(Color backgroundColor)
      Sets the background color of the exported image.

      This property specifies the color used when exporting a worksheet, range, or shape to an image. If no background color has been assigned, this method Sets null.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setBackgroundColor(Color.FromArgb(255, 0, 0));
       
      Parameters:
      backgroundColor - The background color of the exported image. Sets null if no background color has been set.
    • getShowRowHeadings

      public Boolean getShowRowHeadings()
      Gets whether to display row headings.

      This property indicates whether row headings are included when exporting content to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowRowHeadings(true);
       Boolean showRowHeadings = options.getShowRowHeadings();
       
      Returns:
      A Boolean that indicates whether row headings are displayed.
    • setShowRowHeadings

      public void setShowRowHeadings(Boolean showRowHeadings)
      Sets whether to display row headings.

      This property indicates whether row headings are included when exporting content to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowRowHeadings(true);
       
      Parameters:
      showRowHeadings - A Boolean that indicates whether row headings are displayed.
    • getShowColumnHeadings

      public Boolean getShowColumnHeadings()
      Gets whether to display column headings.

      This option controls whether worksheet column headers are included when exporting to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowColumnHeadings(true);
       Boolean showColumnHeadings = options.getShowColumnHeadings();
       
      Returns:
      true to display column headings; false to hide them; or null if this option has not been explicitly set.
    • setShowColumnHeadings

      public void setShowColumnHeadings(Boolean showColumnHeadings)
      Sets whether to display column headings.

      This option controls whether worksheet column headers are included when exporting to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowColumnHeadings(true);
       
      Parameters:
      showColumnHeadings - true to display column headings; false to hide them; or null if this option has not been explicitly set.
    • getShowGridlines

      public Boolean getShowGridlines()
      Gets whether to display gridlines in the exported image.

      This property applies to image export scenarios that use ImageSaveOptions, such as exporting a worksheet or range to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowGridlines(true);
       Boolean showGridlines = options.getShowGridlines();
       
      Returns:
      true to display gridlines in the exported image; otherwise, false.
    • setShowGridlines

      public void setShowGridlines(Boolean showGridlines)
      Sets whether to display gridlines in the exported image.

      This property applies to image export scenarios that use ImageSaveOptions, such as exporting a worksheet or range to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowGridlines(true);
       
      Parameters:
      showGridlines - true to display gridlines in the exported image; otherwise, false.
    • getShowDrawingObjects

      public Boolean getShowDrawingObjects()
      Gets whether to display drawing objects (charts, shapes, and pictures).

      This option controls whether drawing objects are included when exporting to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowDrawingObjects(Boolean.TRUE);
       Boolean showDrawingObjects = options.getShowDrawingObjects();
       
      Returns:
      Boolean.TRUE to display drawing objects; Boolean.FALSE to hide them; or null if this option has not been explicitly set.
    • setShowDrawingObjects

      public void setShowDrawingObjects(Boolean showDrawingObjects)
      Sets whether to display drawing objects (charts, shapes, and pictures).

      This option controls whether drawing objects are included when exporting to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setShowDrawingObjects(Boolean.TRUE);
       
      Parameters:
      showDrawingObjects - Boolean.TRUE to display drawing objects; Boolean.FALSE to hide them; or null if this option has not been explicitly set.
    • getScaleX

      public Double getScaleX()
      Gets the scale on the X axis.

      This value specifies the horizontal scaling used by ImageSaveOptions when exporting to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setScaleX(0.5);
       Double scaleX = options.getScaleX();
       
      Returns:
      The scale on the X axis.
    • setScaleX

      public void setScaleX(Double scaleX)
      Sets the scale on the X axis.

      This value specifies the horizontal scaling used by ImageSaveOptions when exporting to an image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setScaleX(0.5);
       
      Parameters:
      scaleX - The scale on the X axis.
    • getScaleY

      public Double getScaleY()
      Gets the scale on the Y axis.

      This value specifies the vertical scaling used by ImageSaveOptions when exporting to an image. If no Y-axis scale has been assigned, this method returns null.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setScaleY(0.75);
       Double scaleY = options.getScaleY();
       
      Returns:
      The scale on the Y axis. Returns null if no Y-axis scale has been set.
    • setScaleY

      public void setScaleY(Double scaleY)
      Sets the scale on the Y axis.

      This value specifies the vertical scaling used by ImageSaveOptions when exporting to an image. If no Y-axis scale has been assigned, this method Sets null.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setScaleY(0.75);
       
      Parameters:
      scaleY - The scale on the Y axis. Sets null if no Y-axis scale has been set.
    • getResolution

      public Integer getResolution()
      Gets the resolution, in DPI, for JPEG image export.

      This property is used by ImageSaveOptions when exporting a worksheet, range, or shape to a JPEG image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setResolution(192);
       Integer resolution = options.getResolution();
       
      Returns:
      The resolution, in DPI, for JPEG image export.
    • setResolution

      public void setResolution(Integer resolution)
      Sets the resolution, in DPI, for JPEG image export.

      This property is used by ImageSaveOptions when exporting a worksheet, range, or shape to a JPEG image.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setResolution(192);
       
      Parameters:
      resolution - The resolution, in DPI, for JPEG image export.
    • getBlackAndWhite

      public Boolean getBlackAndWhite()
      Gets whether exported images are saved as black and white.

      This property is used by ImageSaveOptions when exporting a worksheet, range, or shape to an image file.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setBlackAndWhite(true);
       Boolean blackAndWhite = options.getBlackAndWhite();
       
      Returns:
      true if exported images are saved as black and white; otherwise, false.
    • setBlackAndWhite

      public void setBlackAndWhite(Boolean blackAndWhite)
      Sets whether exported images are saved as black and white.

      This property is used by ImageSaveOptions when exporting a worksheet, range, or shape to an image file.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setBlackAndWhite(true);
       
      Parameters:
      blackAndWhite - true if exported images are saved as black and white; otherwise, false.
    • getGridlineColor

      public Color getGridlineColor()
      Gets the gridline color.

      This property is used by ImageSaveOptions when exporting a worksheet, range, or shape to an image. If no gridline color has been assigned, this method returns null.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setGridlineColor(Color.FromArgb(0, 0, 255));
       Color gridlineColor = options.getGridlineColor();
       
      Returns:
      The gridline color used for exported images. Returns null if no gridline color has been set.
    • setGridlineColor

      public void setGridlineColor(Color gridlineColor)
      Sets the gridline color.

      This property is used by ImageSaveOptions when exporting a worksheet, range, or shape to an image. If no gridline color has been assigned, this method Sets null.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setGridlineColor(Color.FromArgb(0, 0, 255));
       
      Parameters:
      gridlineColor - The gridline color used for exported images. Sets null if no gridline color has been set.
    • getIncludeAutoMergedCells

      public boolean getIncludeAutoMergedCells()
      Gets whether automatically merged cells are included when exporting to an image.

      This option applies to auto-merge information added by IWorksheet.autoMerge(IRange,AutoMergeDirection,AutoMergeMode,AutoMergeSelectionMode). The default value is false.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setIncludeAutoMergedCells(true);
       boolean includeAutoMergedCells = options.getIncludeAutoMergedCells();
       
      Returns:
      true if automatically merged cells are included when exporting to an image; otherwise, false.
    • setIncludeAutoMergedCells

      public void setIncludeAutoMergedCells(boolean value)
      Sets whether automatically merged cells are included when exporting to an image.

      This option applies to auto-merge information added by IWorksheet.autoMerge(IRange,AutoMergeDirection,AutoMergeMode,AutoMergeSelectionMode). The default value is false.

      
       ImageSaveOptions options = new ImageSaveOptions();
       options.setIncludeAutoMergedCells(true);
       
      Parameters:
      value - true if automatically merged cells are included when exporting to an image; otherwise, false.