刷新链接形状的值

示例

以下屏幕截图显示了下面的示例代码中使用的源Excel文件。它有一个链接的Picture 1与单元格A1相连。我们将使用Aspose.Cells更改单元格A1的值,然后调用Worksheet.getShapes().updateSelectedValue() 方法来刷新Picture 1的值,并以PDF格式保存。

todo:image_alt_text

您可以从以下链接下载 源Excel文件输出PDF

刷新工作表中链接形状的值的Java代码

// 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(RefreshValuesOfLinkedShapes.class);
// Create workbook from source file
Workbook workbook = new Workbook(dataDir + "LinkedShape.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Change the value of cell A1
Cell cell = worksheet.getCells().get("A1");
cell.putValue(100);
// Update the value of the Linked Picture which is linked to cell A1
worksheet.getShapes().updateSelectedValue();
// Save the workbook in pdf format
workbook.save(dataDir + "output.pdf", SaveFormat.PDF);