Actualiser automatiquement l objet OLE via Microsoft Excel avec C++

Contents
[ ]

Le code d’exemple suivant charge le fichier Excel d’exemple qui possède une image OLE non réelle. L’objet OLE est en fait un document Microsoft Word, mais le fichier Excel d’exemple affiche l’image de l’animal au lieu de l’image de Microsoft Word. Cependant, si vous ouvrez le fichier Excel de sortie, vous verrez que Microsoft Excel affiche la bonne image 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();
}