Description
| Inserts a picture into the active worksheet, anchored at the top-left corner of the specified cell. The picture source can be a local file path or a URL (http:// or https://).
When a URL is specified, the image is first downloaded to a temporary file, inserted, and the temporary file is removed afterwards. The picture is stored inside the workbook (SaveWithDocument) and moves with the cell (MoveAndSizeWithCells).
Please take notice that the rows and columns are one-based arrays. Therefore, when referring to Excel cell "A1", row and column numbers are 1 and 1.
Parameter
| Description
| Row
| Long integer, required. The row of the anchor cell.
| Col
| Integer, required. The column of the anchor cell.
| Source
| String, required. Full path to a local image file, or a URL starting with http:// or https://. Supported formats: BMP, JPG, PNG, GIF, TIFF, WMF, EMF.
| WidthPx
| Long integer, optional. Desired width in pixels. When only WidthPx is specified and KeepAspectRatio is True (default), the height is calculated proportionally. When omitted (0), the original image width is used.
| HeightPx
| Long integer, optional. Desired height in pixels. When only HeightPx is specified and KeepAspectRatio is True (default), the width is calculated proportionally. When omitted (0), the original image height is used.
| KeepAspectRatio
| Boolean, optional. When True (default), the image aspect ratio is preserved when only WidthPx or only HeightPx is specified. When both WidthPx and HeightPx are specified, this parameter is ignored and the image is scaled to the exact dimensions. Default value is True.
|
|
Example
| Sub Main If Not XLS.AppInit() Then Exit Sub XLS.AppVisible = True XLS.AddWorkBook XLS.AddWorkSheet "Products" '--- Header row XLS.SetValue 1, 1, "Article|Description|Photo", True '--- Insert a picture from a local file, scaled to 120px wide XLS.InsertPicture 2, 3, "o:\documenten\images\product001.jpg", 120 '--- Insert a picture from a URL, exact 80x80 pixels XLS.InsertPicture 3, 3, _ "https://www.example.com/images/logo.png", 80, 80 '--- Insert at original size (no scaling) XLS.InsertPicture 4, 3, "c:\temp\diagram.png" XLS.SaveWorkBook , , "o:\documenten\productlijst.xlsx" XLS.CloseWorkBook XLS.AppClose End Sub
|