C++でMicrosoft ExcelのOLEオブジェクトを自動的に更新する
Contents
[
Hide
]
Aspose.Cellsは、Microsoft ExcelでExcelファイルを開いたときにOLEオブジェクトを更新する OleObject.GetAutoLoad() プロパティを提供します。これにより、OLEオブジェクトはMicrosoft Excelが生成した正しいOLE画像を表示します。
次のサンプルコードは、非実際のOLE画像を持つ サンプルExcelファイル をロードします。OLEオブジェクトは実際にはMicrosoft Wordドキュメントですが、サンプルExcelファイルではMicrosoft Wordの画像の代わりに動物の画像を表示しています。ただし、出力Excelファイルを開くと、Microsoft Excelが正しいOLE画像を表示しているのが確認できます。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Create workbook object from your sample excel file
Workbook wb(srcDir + u"sample.xlsx");
// Access first worksheet
Worksheet sheet = wb.GetWorksheets().Get(0);
// Set auto load property of first ole object to true
sheet.GetOleObjects().Get(0).SetAutoLoad(true);
// Save the workbook in xlsx format
wb.Save(srcDir + u"RefreshOLEObjects_out.xlsx", SaveFormat::Xlsx);
std::cout << "OLE object refreshed successfully!" << std::endl;
Aspose::Cells::Cleanup();
}