Aggiungi collegamenti ipertestuali alle immagini
Contents
[
Hide
]
collegamenti ipertestuali sono utili per accedere alle informazioni su altri fogli di lavoro o su siti Web. Microsoft Excel consente agli utenti di aggiungere collegamenti ipertestuali al testo nelle celle e nelle immagini. I collegamenti ipertestuali delle immagini possono semplificare la navigazione in un foglio di lavoro, ad esempio come pulsanti Avanti e Indietro o loghi che si collegano a determinati siti. Questo documento spiega come inserire collegamenti ipertestuali di immagini in un foglio di lavoro utilizzando Aspose.Cells.
Aspose.Cells consente di aggiungere collegamenti ipertestuali alle immagini nei fogli di calcolo in fase di esecuzione. È possibile impostare e modificare il suggerimento e l’indirizzo dello schermo del collegamento.
Il codice di esempio seguente illustra come aggiungere un collegamento ipertestuale immagine in un foglio di lavoro.
Quando il codice viene eseguito, salva un file di output con un collegamento ipertestuale immagine al suo interno.
Il file di output
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 | |
String dataDir = Utils.getDataDir(AddImageHyperlinks.class); | |
// Instantiate a new workbook | |
Workbook workbook = new Workbook(); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Insert a string value to a cell | |
worksheet.getCells().get("C2").setValue("Image Hyperlink"); | |
// Set the 4th row height | |
worksheet.getCells().setRowHeight(3, 100); | |
// Set the C column width | |
worksheet.getCells().setColumnWidth(2, 21); | |
// Add a picture to the C4 cell | |
int index = worksheet.getPictures().add(3, 2, 4, 3, dataDir + "aspose-logo.jpg"); | |
// Get the picture object | |
com.aspose.cells.Picture pic = worksheet.getPictures().get(index); | |
// Set the placement type | |
pic.setPlacement(PlacementType.FREE_FLOATING); | |
// Add an image hyperlink | |
pic.addHyperlink("http://www.aspose.com/"); | |
com.aspose.cells.Hyperlink hlink = pic.getHyperlink(); | |
// Specify the screen tip | |
hlink.setScreenTip("Click to go to Aspose site"); | |
// Save the Excel file | |
workbook.save(dataDir + "ImageHyperlink.xls"); |