使用Aspose.Cells自动刷新OLE对象通过Microsoft Excel

使用Aspose.Cells自动刷新OLE对象通过Microsoft Excel

以下示例代码加载了包含非真实OLE图像的样本excel文件。OLE对象实际上是Microsoft Word文档,但示例excel文件显示动物图像而不是Microsoft Word图像。但如果您打开输出excel文件,您将看到Microsoft Excel显示正确的OLE图像。

下面的截图显示了在Microsoft Excel中打开时的示例excel文件的样子。

todo:image_alt_text

下面的截图显示了在Microsoft Excel中打开时的输出excel文件的样子。

todo:image_alt_text

// 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);