Aggiorna automaticamente l oggetto OLE tramite Microsoft Excel con C++
Contents
[
Hide
]
Aspose.Cells fornisce la proprietà OleObject.GetAutoLoad() per aggiornare l’oggetto OLE quando il file Excel viene aperto in Microsoft Excel. Grazie a questa proprietà, l’oggetto OLE mostrerà l’immagine OLE corretta generata da Microsoft Excel.
Il codice di esempio seguente carica il file Excel di esempio che contiene un’immagine OLE non reale. L’oggetto OLE è in realtà un documento Microsoft Word, ma il file Excel di esempio mostra invece l’immagine dell’animale. Tuttavia, se apri il file Excel di output, vedrai che Microsoft Excel visualizza l’immagine OLE corretta.
#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();
}