Aspose.Cellsを使用してMicrosoft ExcelでOLEオブジェクトを自動的に更新する
Contents
[
Hide
]
Aspose.Cellsは、ExcelファイルがMicrosoft Excelで開かれるときにOLEオブジェクトを再表示するためのOleObject.AutoLoadプロパティを提供します。このプロパティにより、OLEオブジェクトは、Microsoft Excelによって生成された正しいOLEイメージを表示します。
次のサンプルコードでは、実際の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); |