[]
XlsmSaveOptions, XltxSaveOptionsUse 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);
final booleanfinal booleanfinal booleanbooleanfinal booleanfinal booleanfinal booleanfinal booleanfinal Stringfinal voidsetExcludeEmptyRegionCells(boolean value) final voidsetExcludeUnusedNames(boolean value) final voidsetExcludeUnusedStyles(boolean value) voidsetExportSharedFormula(boolean value) final voidsetIgnoreFormulas(boolean value) final voidsetIncludeAutoMergedCells(boolean value) final voidsetIncludeBindingSource(boolean value) final voidsetIsCompactMode(boolean value) final voidsetPassword(String value) toString()getFileFormat, setFileFormatXlsxSaveOptions. 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);
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);
null if no password has been set.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);
value - The password used to encrypt the saved xlsx file, or null if no password has been set.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);
true if the workbook is saved in compact mode; otherwise, false. The default value is false.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);
value - true if the workbook is saved in compact mode; otherwise, false. The default value is false.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);
true if formula cells are exported as value cells when saving; otherwise, false.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);
value - true if formula cells are exported as value cells when saving; otherwise, false.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);
true if unused user-defined cell styles are excluded during XLSX export; otherwise, false.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);
value - true if unused user-defined cell styles are excluded during XLSX export; otherwise, false.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);
true if unused defined names are excluded during XLSX export; otherwise, false.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);
value - true if unused defined names are excluded during XLSX export; otherwise, false.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);
true if empty cells outside the used data range are excluded when saving the workbook; otherwise, false.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);
value - true if empty cells outside the used data range are excluded when saving the workbook; otherwise, false.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);
true if the binding source is included when saving the file; otherwise, false.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);
value - true if the binding source is included when saving the file; otherwise, false.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);
true if automatically merged cells are included when saving the workbook; otherwise, false.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);
value - true if automatically merged cells are included when saving the workbook; otherwise, false.