How to set AutoRecover property of Workbook

Java code to set AutoRecover property of Workbook

The following code explains how to use Workbook.getSettings().setAutoRecover() property of the workbook. The code first reads the default value of this property which is true, then it sets it as false and saves the workbook. Then it reads the workbook again and reads the value of this property which is false at this time.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(SetAutoRecoverProperty.class);
// Create workbook object
Workbook workbook = new Workbook();
// Read AutoRecover property
System.out.println("AutoRecover: " + workbook.getSettings().getAutoRecover());
// Set AutoRecover property to false
workbook.getSettings().setAutoRecover(false);
// Save the workbook
workbook.save("output.xlsx");
// Read the saved workbook again
workbook = new Workbook("output.xlsx");
// Read AutoRecover property
System.out.println("AutoRecover: " + workbook.getSettings().getAutoRecover());

Output generated by sample code

Here is the console output of the above sample code.

AutoRecover: true

AutoRecover: false