How to set AutoRecover property of Workbook
You can use Aspose.Cells to set AutoRecover property of workbook. The default value of this property is true. When you set it false on a workbook, Microsoft Excel disables AutoRecover (Autosave) on that Excel file.
Aspose.Cells provides Workbook.Settings.AutoRecover property to enable or disable this option.
The following code explains how to use Workbook.Settings.AutoRecover 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.
C# code to set the AutoRecover property of Workbook
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object | |
Workbook workbook = new Workbook(); | |
// Read AutoRecover property | |
Console.WriteLine("AutoRecover: " + workbook.Settings.AutoRecover); | |
// Set AutoRecover property to false | |
workbook.Settings.AutoRecover = false; | |
// Save the workbook | |
workbook.Save(dataDir + "output_out.xlsx"); | |
// Read the saved workbook again | |
workbook = new Workbook(dataDir + "output_out.xlsx"); | |
// Read AutoRecover property | |
Console.WriteLine("AutoRecover: " + workbook.Settings.AutoRecover); |
Output
Here is the console output of the above sample code.
AutoRecover: True
AutoRecover: False