Class SaveOptions

java.lang.Object
io.keikai.axyra.sheets.io.SaveOptions

public final class SaveOptions extends Object
Export options for Workbook.save(path, options). Every field defaults to full-fidelity export. Saved formula results are current, since writes recalculate their dependents; only a workbook in CalcMode.MANUAL needs Workbook.recalculate() before saving.

Only the XLSX family (.xlsx, .xlsm, .xltx, .xltm) honors these options. Other formats are written as Workbook.save(Path) writes them and ignore the options. One check applies to other formats: an explicit FormulaPolicy.KEEP is refused for output that cannot keep formulas (see formulaPolicy(FormulaPolicy)).


 workbook.save(Path.of("values.xlsx"),
         SaveOptions.create().formulaPolicy(FormulaPolicy.VALUES_ONLY).skipComments(true));
 
  • Constructor Details

    • SaveOptions

      public SaveOptions()
  • Method Details

    • create

      public static SaveOptions create()
      Options with every field at its full-fidelity default: formulas kept, comments and hyperlinks written.
      Returns:
      new options
    • formulaPolicy

      public SaveOptions formulaPolicy(FormulaPolicy policy)
      Sets how formulas are written. Asking for FormulaPolicy.KEEP explicitly is a promise that the file keeps its formulas. So Workbook.save throws IllegalArgumentException instead of writing values when the target cannot keep them: always for .csv, .tsv and .txt, and for .ods when a formula has no OpenFormula translation. Leaving the policy at its default KEEP does not trigger this check.
      Parameters:
      policy - the policy
      Returns:
      these options
      Throws:
      NullPointerException - if policy is null
    • skipComments

      public SaveOptions skipComments(boolean skip)
      Leaves cell comments (notes) out of the saved XLSX file (true). The workbook in memory keeps them. Default false.
      Parameters:
      skip - true to leave comments out
      Returns:
      these options
    • skipHyperlinks

      public SaveOptions skipHyperlinks(boolean skip)
      Leaves hyperlinks out of the saved XLSX file (true). The cell text stays, and the workbook in memory keeps the links. Default false.
      Parameters:
      skip - true to leave hyperlinks out
      Returns:
      these options
    • formulaPolicy

      public FormulaPolicy formulaPolicy()
      The formula policy; FormulaPolicy.KEEP by default.
    • formulaPolicyExplicit

      public boolean formulaPolicyExplicit()
      Whether formulaPolicy(FormulaPolicy) was called, rather than left at the default.
    • skipComments

      public boolean skipComments()
      Whether comments are left out of the saved file.
    • skipHyperlinks

      public boolean skipHyperlinks()
      Whether hyperlinks are left out of the saved file.