Insérer une image liée à partir de l adresse Web
Insertion d’une image liée à partir de l’adresse web
Utilisation de Microsoft Excel
Dans Microsoft Excel (par exemple 2007) :
- Cliquez sur le menu Insérer et sélectionnez Image.
- Spécifiez l’adresse web de l’image dans la boîte de dialogue Insérer une image.
L’image est insérée.
Utilisation de Aspose.Cells for Java
Aspose.Cells for Java prend en charge l’ajout d’une image liée à l’aide de la méthode ShapeCollection.addLinkedPicture(int upperLeftRow, int upperLeftColumn, int height, int width, java.lang.String sourceFullName).
La méthode renvoie un objet Picture.
L’exemple suivant montre comment ajouter une image liée à partir de l’adresse Web à une feuille de calcul.
Après l’exécution du code, le fichier Excel généré contient une image liée sur la première feuille de calcul.
Le fichier de sortie
// 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(InsertLinkedPicturefromWebAddress.class); | |
// Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
// Insert a linked picture (from Web Address) to B2 Cell. | |
Picture pic = (Picture) workbook.getWorksheets().get(0).getShapes().addLinkedPicture(1, 1, 100, 100, | |
"http://www.aspose.com/Images/aspose-logo.jpg"); | |
// Set the source of the inserted image. | |
pic.setSourceFullName("http://www.aspose.com/images/aspose-logo.gif"); | |
// Set the height and width of the inserted image. | |
pic.setHeightInch(1.04); | |
pic.setWidthInch(2.6); | |
// Save the Excel file. | |
workbook.save(dataDir + "LinkedPicture.xlsx"); |