Insérer une image liée à partir d'une adresse Web
Contents
[
Hide
]
Parfois, vous devez insérer une image provenant du Web (http://) dans une feuille de calcul. Pour ce faire, indiquez l’URL de l’image et l’image sera téléchargée à chaque ouverture de la feuille de calcul dans Microsoft Excel. L’image n’est pas physiquement intégrée dans le document Excel, mais pointe vers une ressource Web.
Utilisation d’Excel Microsoft
Dans Microsoft Excel (par exemple 2007) :
- Clique leInsérer menu et sélectionnezPhoto.
- Spécifiez l’adresse Web de l’image dans la boîte de dialogue Insérer une image.
En utilisant Aspose.Cells for .NET
Aspose.Cells for .NET prend en charge l’ajout d’une image liée à l’aide de laShapeCollection.AddLinkedPicture(int upperLeftRow, int upperLeftColumn, int heightPixels, int widthPixels, string sourceFullName) . La méthode retourne unPhotoobjet.
L’exemple suivant montre comment ajouter une image liée à partir d’une adresse Web à une feuille de calcul.
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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
// Insert a linked picture (from Web Address) to B2 Cell. | |
Aspose.Cells.Drawing.Picture pic = workbook.Worksheets[0].Shapes.AddLinkedPicture(1, 1, 100, 100, "http:// Www.aspose.com/Images/aspose-logo.jpg"); | |
// Set the height and width of the inserted image. | |
pic.HeightInch = 1.04; | |
pic.WidthInch = 2.6; | |
// Save the Excel file. | |
workbook.Save(dataDir+ "outLinkedPicture.out.xlsx"); |