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 linked to cells A1 to E4. We will change the value of cell B4 with Aspose.Cells and then call Worksheet.Shapes.UpdateSelectedValue() method to refresh the value of the picture and save it in PDF format.
You can download the source Excel file and the output PDF from the given links.
C# 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-.NET | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
//Output directory | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Create workbook from source file | |
Workbook workbook = new Workbook(sourceDir + "sampleRefreshValueOfLinkedShapes.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Change the value of cell B4 | |
Cell cell = worksheet.Cells["B4"]; | |
cell.PutValue(100); | |
// Update the value of the Linked Picture which is linked to cell B4 | |
worksheet.Shapes.UpdateSelectedValue(); | |
// Save the workbook in PDF format | |
workbook.Save(outputDir + "outputRefreshValueOfLinkedShapes.pdf", SaveFormat.Pdf); |