Automatically refresh OLE object via Microsoft Excel using Aspose.Cells
Automatically refresh OLE object via Microsoft Excel using Aspose.Cells
The following sample code loads the sample excel file which has a non-real OLE image. The OLE object is actually a Microsoft Word document but the sample excel file shows the animal image instead of Microsoft Word image. But if you open the output excel file, you will see Microsoft Excel displays the correct OLE image.
The following screenshot shows how the sample excel file looks when opened in Microsoft Excel.
The following screenshot shows how the output excel file looks when opened in Microsoft Excel.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(AutomaticallyrefreshOLEobject.class); | |
// Create workbook object from your sample excel file | |
Workbook wb = new Workbook(dataDir + "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 worbook in xlsx format | |
wb.save(dataDir + "output.xlsx", SaveFormat.XLSX); |