Aggiorna i valori delle forme collegate
Contents
[
Hide
]
volte, hai una forma collegata nel tuo file Excel che è collegata a qualche cella. In Microsoft Excel, la modifica del valore della cella collegata modifica anche il valore della forma collegata. Funziona bene anche con Aspose.Cells se si desidera salvare la cartella di lavoro nel formato XLS o XLSX. Tuttavia, se desideri salvare la tua cartella di lavoro nel formato PDF o HTML, dovrai chiamareWorksheet.getShapes().updateSelectedValue() per aggiornare il valore della forma collegata.
Esempio
Lo screenshot seguente mostra il file Excel di origine utilizzato nel codice di esempio riportato di seguito. Ha un collegamentoImmagine 1 collegato alla cella A1. Cambieremo il valore della cella A1 con Aspose.Cells e quindi chiameremoWorksheet.getShapes().updateSelectedValue() metodo per aggiornare il valore diImmagine 1 e salvalo nel formato PDF.
Puoi scaricare ilfile Excel di origine e iluscita PDF dai link indicati.
Java codice per aggiornare i valori delle forme collegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RefreshValuesOfLinkedShapes.class); | |
// Create workbook from source file | |
Workbook workbook = new Workbook(dataDir + "LinkedShape.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Change the value of cell A1 | |
Cell cell = worksheet.getCells().get("A1"); | |
cell.putValue(100); | |
// Update the value of the Linked Picture which is linked to cell A1 | |
worksheet.getShapes().updateSelectedValue(); | |
// Save the workbook in pdf format | |
workbook.save(dataDir + "output.pdf", SaveFormat.PDF); |