[]
        
(Showing Draft Content)

XlsxSaveOptions

Class XlsxSaveOptions

java.lang.Object
com.grapecity.documents.excel.SaveOptionsBase
com.grapecity.documents.excel.XlsxSaveOptions
Direct Known Subclasses:
XlsmSaveOptions, XltxSaveOptions

public class XlsxSaveOptions extends SaveOptionsBase
Represents options for saving a workbook as an .xlsx file.

Use this class to control how GcExcel exports workbook content to the XLSX format. It supports settings for password protection, shared formula export, compact mode, formula handling, binding source export, auto-merged cells, and excluding unused styles, names, or empty region cells to reduce file size.


 XlsxSaveOptions options = new XlsxSaveOptions();
 String password = getWorkbookPassword();
 options.setPassword(password);
 options.setExcludeUnusedStyles(true);
 options.setExportSharedFormula(false);
 workbook.save("path/to/output.xlsx", options);
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of XlsxSaveOptions.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Gets whether to exclude empty cells outside the used data range when saving the workbook.
    final boolean
    Gets whether user-defined but unused defined names are excluded when saving the workbook to an XLSX file.
    final boolean
    Gets whether user-defined but unused cell styles are excluded when saving the workbook to an XLSX file.
    boolean
    Gets whether to export shared formulas when saving the workbook.
    final boolean
    Gets whether formula cells are treated as value cells when saving to an .xlsx file.
    final boolean
    Gets whether automatically merged cells are included when saving the workbook to an .xlsx file.
    final boolean
    Gets whether to include the binding source when saving the file.
    final boolean
    Gets whether to save the workbook in compact mode.
    final String
    Gets the password used to encrypt the saved xlsx file.
    final void
    Sets whether to exclude empty cells outside the used data range when saving the workbook.
    final void
    setExcludeUnusedNames(boolean value)
    Sets whether user-defined but unused defined names are excluded when saving the workbook to an XLSX file.
    final void
    setExcludeUnusedStyles(boolean value)
    Sets whether user-defined but unused cell styles are excluded when saving the workbook to an XLSX file.
    void
    setExportSharedFormula(boolean value)
    Sets whether to export shared formulas when saving the workbook.
    final void
    setIgnoreFormulas(boolean value)
    Sets whether formula cells are treated as value cells when saving to an .xlsx file.
    final void
    Sets whether automatically merged cells are included when saving the workbook to an .xlsx file.
    final void
    setIncludeBindingSource(boolean value)
    Sets whether to include the binding source when saving the file.
    final void
    setIsCompactMode(boolean value)
    Sets whether to save the workbook in compact mode.
    final void
    Sets the password used to encrypt the saved xlsx file.
    Returns a string representation of these XLSX save options.

    Methods inherited from class com.grapecity.documents.excel.SaveOptionsBase

    getFileFormat, setFileFormat

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • XlsxSaveOptions

      public XlsxSaveOptions()
      Creates a new instance of XlsxSaveOptions.

      This constructor initializes the option object to use SaveFileFormat.Xlsx. Configure XLSX-specific settings before passing the options to a workbook save API.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       String password = getWorkbookPassword();
       options.setPassword(password);
       options.setExcludeUnusedStyles(true);
       options.setExportSharedFormula(false);
       workbook.save("path/to/output.xlsx", options);
       
  • Method Details

    • getExportSharedFormula

      public boolean getExportSharedFormula()
      Gets whether to export shared formulas when saving the workbook.

      Shared formula export is enabled by default. This option can be useful when working with third-party libraries that do not support shared formulas.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExportSharedFormula(false);
       boolean exportSharedFormula = options.getExportSharedFormula();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if shared formulas are exported when saving the workbook; otherwise, false. The default value is true.
    • setExportSharedFormula

      public void setExportSharedFormula(boolean value)
      Sets whether to export shared formulas when saving the workbook.

      Shared formula export is enabled by default. This option can be useful when working with third-party libraries that do not support shared formulas.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExportSharedFormula(false);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if shared formulas are exported when saving the workbook; otherwise, false. The default value is true.
    • getPassword

      public final String getPassword()
      Gets the password used to encrypt the saved xlsx file.

      Use this method to retrieve the password configured on this XlsxSaveOptions instance before saving a workbook with password protection.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       String configuredPassword = getWorkbookPassword();
       options.setPassword(configuredPassword);
       String password = options.getPassword();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      The password used to encrypt the saved xlsx file, or null if no password has been set.
    • setPassword

      public final void setPassword(String value)
      Sets the password used to encrypt the saved xlsx file.

      Use this method to set the password configured on this XlsxSaveOptions instance before saving a workbook with password protection.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       String password = getWorkbookPassword();
       options.setPassword(password);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - The password used to encrypt the saved xlsx file, or null if no password has been set.
    • getIsCompactMode

      public final boolean getIsCompactMode()
      Gets whether to save the workbook in compact mode.

      When this option is true, the generated .xlsx content is written in a more compact form. For example, during export, explicit row and cell references can be omitted for contiguous rows and columns. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIsCompactMode(true);
       boolean compactMode = options.getIsCompactMode();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if the workbook is saved in compact mode; otherwise, false. The default value is false.
    • setIsCompactMode

      public final void setIsCompactMode(boolean value)
      Sets whether to save the workbook in compact mode.

      When this option is true, the generated .xlsx content is written in a more compact form. For example, during export, explicit row and cell references can be omitted for contiguous rows and columns. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIsCompactMode(true);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if the workbook is saved in compact mode; otherwise, false. The default value is false.
    • getIgnoreFormulas

      public final boolean getIgnoreFormulas()
      Gets whether formula cells are treated as value cells when saving to an .xlsx file.

      When this property is true, formula cells are exported as value cells in Excel instead of preserving their formulas.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIgnoreFormulas(true);
       boolean ignoreFormulas = options.getIgnoreFormulas();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if formula cells are exported as value cells when saving; otherwise, false.
    • setIgnoreFormulas

      public final void setIgnoreFormulas(boolean value)
      Sets whether formula cells are treated as value cells when saving to an .xlsx file.

      When this property is true, formula cells are exported as value cells in Excel instead of preserving their formulas.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIgnoreFormulas(true);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if formula cells are exported as value cells when saving; otherwise, false.
    • getExcludeUnusedStyles

      public final boolean getExcludeUnusedStyles()
      Gets whether user-defined but unused cell styles are excluded when saving the workbook to an XLSX file.

      If this property is true, user-defined cell styles that are never applied in the workbook are omitted during export. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExcludeUnusedStyles(true);
       boolean excludeUnusedStyles = options.getExcludeUnusedStyles();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if unused user-defined cell styles are excluded during XLSX export; otherwise, false.
    • setExcludeUnusedStyles

      public final void setExcludeUnusedStyles(boolean value)
      Sets whether user-defined but unused cell styles are excluded when saving the workbook to an XLSX file.

      If this property is true, user-defined cell styles that are never applied in the workbook are omitted during export. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExcludeUnusedStyles(true);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if unused user-defined cell styles are excluded during XLSX export; otherwise, false.
    • getExcludeUnusedNames

      public final boolean getExcludeUnusedNames()
      Gets whether user-defined but unused defined names are excluded when saving the workbook to an XLSX file.

      If this property is true, unused defined names are omitted during export. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExcludeUnusedNames(true);
       boolean excludeUnusedNames = options.getExcludeUnusedNames();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if unused defined names are excluded during XLSX export; otherwise, false.
    • setExcludeUnusedNames

      public final void setExcludeUnusedNames(boolean value)
      Sets whether user-defined but unused defined names are excluded when saving the workbook to an XLSX file.

      If this property is true, unused defined names are omitted during export. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExcludeUnusedNames(true);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if unused defined names are excluded during XLSX export; otherwise, false.
    • getExcludeEmptyRegionCells

      public final boolean getExcludeEmptyRegionCells()
      Gets whether to exclude empty cells outside the used data range when saving the workbook.

      Empty cells in this context are cells that contain no data or only style information. When this option is true, those cells are excluded during save. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExcludeEmptyRegionCells(true);
       boolean excludeEmptyRegionCells = options.getExcludeEmptyRegionCells();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if empty cells outside the used data range are excluded when saving the workbook; otherwise, false.
    • setExcludeEmptyRegionCells

      public final void setExcludeEmptyRegionCells(boolean value)
      Sets whether to exclude empty cells outside the used data range when saving the workbook.

      Empty cells in this context are cells that contain no data or only style information. When this option is true, those cells are excluded during save. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setExcludeEmptyRegionCells(true);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if empty cells outside the used data range are excluded when saving the workbook; otherwise, false.
    • getIncludeBindingSource

      public final boolean getIncludeBindingSource()
      Gets whether to include the binding source when saving the file.

      This property controls whether a bound data source is exported to the .xlsx file. The default value is true.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIncludeBindingSource(false);
       boolean includeBindingSource = options.getIncludeBindingSource();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if the binding source is included when saving the file; otherwise, false.
    • setIncludeBindingSource

      public final void setIncludeBindingSource(boolean value)
      Sets whether to include the binding source when saving the file.

      This property controls whether a bound data source is exported to the .xlsx file. The default value is true.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIncludeBindingSource(false);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if the binding source is included when saving the file; otherwise, false.
    • getIncludeAutoMergedCells

      public final boolean getIncludeAutoMergedCells()
      Gets whether automatically merged cells are included when saving the workbook to an .xlsx file.

      When this option is true, auto-merge information is included during export so the automatically merged cells are written to the .xlsx file. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIncludeAutoMergedCells(true);
       boolean includeAutoMergedCells = options.getIncludeAutoMergedCells();
       workbook.save("path/to/output.xlsx", options);
       
      Returns:
      true if automatically merged cells are included when saving the workbook; otherwise, false.
    • setIncludeAutoMergedCells

      public final void setIncludeAutoMergedCells(boolean value)
      Sets whether automatically merged cells are included when saving the workbook to an .xlsx file.

      When this option is true, auto-merge information is included during export so the automatically merged cells are written to the .xlsx file. The default value is false.

      
       XlsxSaveOptions options = new XlsxSaveOptions();
       options.setIncludeAutoMergedCells(true);
       workbook.save("path/to/output.xlsx", options);
       
      Parameters:
      value - true if automatically merged cells are included when saving the workbook; otherwise, false.
    • toString

      public String toString()
      Returns a string representation of these XLSX save options.
      Overrides:
      toString in class Object
      Returns:
      A string representation of these XLSX save options.