Aggiorna i valori delle forme collegate con Node.js tramite 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 ShapeCollection.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 Node.js per aggiornare i valori delle forme collegate
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Source directory
const sourceDir = path.join(__dirname, "data");
// Output directory
const outputDir = path.join(__dirname, "output");
// Create workbook from source file
const workbook = new AsposeCells.Workbook(path.join(sourceDir, "sampleRefreshValueOfLinkedShapes.xlsx"));
// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Change the value of cell B4
const cell = worksheet.getCells().get("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(path.join(outputDir, "outputRefreshValueOfLinkedShapes.pdf"), AsposeCells.SaveFormat.Pdf);