Refresh Values of Linked Shapes with C++
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
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create workbook from source file
Workbook workbook(srcDir + u"sampleRefreshValueOfLinkedShapes.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Change the value of cell B4
Cell cell = worksheet.GetCells().Get(u"B4");
cell.PutValue(100);
// Update the value of the Linked Picture which is linked to cell B4
worksheet.GetShapes().UpdateSelectedValue();
// Save the workbook in PDF format
workbook.Save(outDir + u"outputRefreshValueOfLinkedShapes.pdf", SaveFormat::Pdf);
std::cout << "Linked shapes value refreshed successfully!" << std::endl;
Aspose::Cells::Cleanup();
}