如何设置工作簿的AutoRecover属性
Contents
[
Hide
]
您可以使用Aspose.Cells来设置工作簿的AutoRecover属性。 该属性的默认值为true。 当您在工作簿上将其设置为false时,Microsoft Excel会禁用该Excel文件上的AutoRecover(自动保存)。
Aspose.Cells提供了Workbook.Settings.AutoRecover属性来启用或禁用此选项。
以下代码解释了如何使用工作簿的Workbook.Settings.AutoRecover属性。 代码首先读取该属性的默认值,该值为true,然后将其设置为false并保存工作簿。 然后再次读取工作簿并读取该属性的值,此时该值为false。
C#代码设置工作簿的AutoRecover属性
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
输出
这是上面示例代码的控制台输出。
AutoRecover: True
AutoRecover: False