XL.Book.AddPictureContainer
---------------------------

Adds a picture to the workbook from container.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XL](component_XL.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XL.Book.AddPictureContainer"; BookRef; Container ) 

**MBS**( **"XL.Book.AddPictureContainer";** /\* Adds a picture to the workbook from container. \*/  
**$BookRef**; /\* The reference number for the workbook.e.g. $ref \*/   
**$Container**) /\* The container value with the image inside. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| BookRef | The reference number for the workbook. | $ref |
| Container | The container value with the image inside. | $container |

### Result

Returns image number or error.

### Description

Adds a picture to the workbook from container.  
Returns a picture identifier. Supports BMP, DIB, PNG, JPG and WMF picture formats.   
Use picture identifier with [XL.Sheet.SetPictureWithScale](XLSheetSetPictureWithScale.md) or [XL.Sheet.SetPictureWithSize](XLSheetSetPictureWithSize.md) functions.  
  
For XLSX files you can embed SVG graphics with LibXL 4.2 or newer.  
### Examples

Add a picture to excel sheet:

 # add picture to file   
Set Variable \[$logoID ; Value:MBS ( "XL.Book.AddPictureContainer"; $book ; Writing data::Logo )\]  
\# position with size:   
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.SetPictureWithSize](XLSheetSetPictureWithSize.md)"; $book ; $sheet ; 2; 1; $logoID ; 100; 100)\]  
\# or with factor:   
Set Variable \[$r ; Value:MBS ( "[XL.Sheet.SetPictureWithScale](XLSheetSetPictureWithScale.md)"; $book ; $sheet ; 2; 1; $logoID ; .2)\]  
Adds picture with proportional scaled image:

 Set Variable \[ $image ; Value: MBS ( "[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Writing data::Logo ) \]   
If \[ MBS ("IsError") = 0 \]   
 Set Variable \[ $destWidth ; Value: 120 \]   
 Set Variable \[ $destHeight ; Value: 120 \]   
 Set Variable \[ $width ; Value: MBS ( "[GMImage.GetWidth](GMImageGetWidth.md)"; $image ) \]   
 Set Variable \[ $height ; Value: MBS ( "[GMImage.GetHeight](GMImageGetHeight.md)"; $image ) \]   
 Set Variable \[ $r ; Value: MBS ( "[GMImage.Release](GMImageRelease.md)"; $image ) \]   
 Set Variable \[ $factor ; Value: Min ( $destheight / $height ; $destwidth / $width ) \]   
 Set Variable \[ $dwidth ; Value: $width \* $factor \]   
 Set Variable \[ $dheight ; Value: $height \* $factor \]   
 #   
 Set Variable \[ $logoID ; Value: MBS ( "XL.Book.AddPictureContainer"; $book ; Writing data::Logo ) \]   
 If \[ MBS ("IsError") = 0 \]   
 Set Variable \[ $r ; Value: MBS ( "[XL.Sheet.SetPictureWithSize](XLSheetSetPictureWithSize.md)"; $book ; $sheet ; 2; 1; $logoID ; $dwidth ; $dheight ) \]   
 End If  
End If  
### See also

- [GMImage.GetHeight](GMImageGetHeight.md)
- [GMImage.GetWidth](GMImageGetWidth.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.NewFromContainer](GMImageNewFromContainer.md)
- [GMImage.Release](GMImageRelease.md)
- [IsError](IsError.md)
- [XL.Format.SetWrap](XLFormatSetWrap.md)
- [XL.Sheet.SetCol](XLSheetSetCol.md)
- [XL.Sheet.SetPictureWithScale](XLSheetSetPictureWithScale.md)
- [XL.Sheet.SetPictureWithSize](XLSheetSetPictureWithSize.md)

### Example Databases

- [XL/Writing data](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XL/Writing%20data.shtml#5ScriptAnchor_)

### Blog Entries

- [LibXL for FileMaker with extras](https://www.mbsplugins.de/archive/2021-03-02/LibXL_for_FileMaker_with_extra/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2025, Seite 29](https://filemaker-magazin.de/neuigkeit/4282-Appetithappen-FMM_202501)

This function checks for a license.

Created 18th August 2014 , last changed 2nd April 2024

  
[XL.Book.AddFormatFromBook](XLBookAddFormatFromBook.md) - [XL.Book.AddPictureFile](XLBookAddPictureFile.md)

[HTML Version](XLBookAddPictureContainer.shtml)