Refresh Values of Linked Shapes
Example
The following screenshot shows the source Excel file used in the sample code below. It has a linked Picture 1 linked to cell A1. We will change the value of cell A1 with Aspose.Cells and then call Worksheet.getShapes().updateSelectedValue() method to refresh the value of Picture 1 and save it in PDF format.
You can download the source Excel file and the output PDF from the given links.
Java code to refresh the values of linked shapes
// 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); |