Aggiorna i valori delle forme collegate con C++
Esempio
Lo screenshot seguente mostra il file Excel di origine utilizzato nel codice di esempio qui sotto. Ha un’immagine collegata collegata alle celle A1 a E4. Modificheremo il valore della cella B4 con Aspose.Cells e poi chiameremo il metodo Worksheet.Shapes.UpdateSelectedValue() per aggiornare il valore dell’immagine e salvarlo in formato PDF.
Puoi scaricare il file Excel di origine e il PDF di output dai link forniti.
Codice C++ per aggiornare i valori delle forme collegate
#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();
}