Aggiorna i valori delle forme collegate
Esempio
La schermata seguente mostra il file Excel di origine utilizzato nel codice di esempio qui sotto. Ha un’immagine collegata collegata alle celle da A1 a E4. Cambieremo 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.
È possibile scaricare il file Excel di origine e il PDF di output dai link forniti.
Codice C# per aggiornare i valori delle forme collegate
// 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); |