使用Aspose.Cells自动刷新OLE对象通过Microsoft Excel
Contents
[
Hide
]
Aspose.Cells提供 OleObject.AutoLoad 属性,在Microsoft Excel中打开excel文件时刷新OLE对象。由于该属性,OLE对象将显示由Microsoft Excel生成的正确OLE图像。
以下样本代码加载了包含非真实OLE图像的 样本excel文件。OLE对象实际上是一个Microsoft Word文档,但样本excel文件显示的是动物图像,而不是Microsoft Word图像。但是,如果打开 输出excel文件,您将看到Microsoft Excel显示了正确的OLE图像。
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 from your sample excel file | |
Workbook wb = new Workbook(dataDir + "sample.xlsx"); | |
// Access first worksheet | |
Worksheet sheet = wb.Worksheets[0]; | |
// Set auto load property of first ole object to true | |
sheet.OleObjects[0].AutoLoad = true; | |
// Save the worbook in xlsx format | |
wb.Save(dataDir + "RefreshOLEObjects_out.xlsx", SaveFormat.Xlsx); |