Pictures
- 4 minutes to read
The SpreadsheetControl provides the capability to insert pictures into a spreadsheet document. An individual image embedded in a worksheet is represented by the Picture object, which inherits the base Shape interface. All images are stored in the PictureCollection, accessible via the Worksheet.Pictures property. To create a picture and add it to a worksheet programmatically, use the PictureCollection.AddPicture method. For an example, refer to the How to: Insert and Delete Pictures topic.
To enable end-users to insert pictures in a worksheet, add the Illustrations Ribbon page group to the SpreadsheetControl. For an example on how to provide a Ribbon UI for the SpreadsheetControl, see the Getting Started topic.
The SpreadsheetControl supports graphics of the following types.
- Bitmap (*.bmp, *.dib)
- JPEG File Interchange Format (*.jpg, *.jpeg)
- Portable Network Graphics (*.png)
- Graphics Interchange Format (*.gif)
- Tagged Image File Format (*.tif, *.tiff)
- Microsoft Enhanced Metafile (*.emf)
- Windows Metafile (*.wmf)
The SpreadsheetControl allows end-users to move, resize and rotate embedded pictures, as described in the table below. For an example on how to modify pictures in a worksheet programmatically, refer to the How to: Modify an Embedded Picture document.
Action | End-User Capabilities | API properties/methods |
---|---|---|
Move a picture | Click the picture you wish to move and drag it to a new location. | |
Resize a picture | Click the rotation handle of the selected picture and drag it in the direction in which you wish to rotate the object. |
FloatingObject.LockAspectRatio |
Rotate a picture | Drag the sizing handle away from the center (or towards the center) of the selected picture, and release it once the desired size is reached. |
End-User Restrictions
The SpreadsheetControl allows you to prevent end-users from modifying pictures embedded in a worksheet. To implement end-user restrictions, use the SpreadsheetControlOptions.Behavior property, which provides access to the restriction settings. The table below lists possible restrictions you can set when working with pictures in the SpreadsheetControl.
Restriction | Description |
---|---|
SpreadsheetDrawingBehaviorOptions.Move | Gets or sets whether or not end-users are allowed to change the position of pictures. |
SpreadsheetDrawingBehaviorOptions.Resize | Gets or sets whether or not end-users are allowed to change the size of pictures. |
SpreadsheetDrawingBehaviorOptions.Rotate | Gets or sets whether or not end-users are allowed to rotate pictures. |
SpreadsheetDrawingBehaviorOptions.ChangeZOrder | Gets or sets whether or not end-users are allowed to change the order of pictures in a worksheet. |
Set the desired property to the DocumentCapability.Disabled or DocumentCapability.Hidden value, to make the operation unavailable, and disable or hide the Bring Forward and Send Backward commands in the Ribbon UI and the spreadsheet popup menu.
Supported Keyboard Shortcuts
The SpreadsheetControl also provides the capability for end-users to use key combinations to quickly perform operations with pictures.
Shortcut | Description |
---|---|
DELETE | Deletes the selected picture. |
BACKSPACE | Deletes the selected picture. |
ARROW KEYS | Move the selected picture in a worksheet. |
ALT+LEFT ARROW KEY | Rotates the selected picture counterclockwise by 15 degrees. |
CTRL+ALT+LEFT ARROW KEY | Rotates the selected picture counterclockwise by 1 degree. |
ALT+RIGHT ARROW KEY | Rotates the selected picture clockwise by 15 degrees. |
CTRL+ALT+RIGHT ARROW KEY | Rotates the selected picture clockwise by 1 degree. |
SHIFT+RIGHT ARROW KEY | Increases the width and height of the selected picture by 10%. |
SHIFT+UP ARROW KEY | Increases the width and height of the selected picture by 10%. |
CTRL+SHIFT+RIGHT ARROW KEY | Increases the width and height of the selected picture by 1%. |
CTRL+SHIFT+UP ARROW KEY | Increases the width and height of the selected picture by 1%. |
SHIFT+LEFT ARROW KEY | Decreases the width and height of the selected picture by 10%. |
SHIFT+DOWN ARROW KEY | Decreases the width and height of the selected picture by 10%. |
CTRL+SHIFT+LEFT ARROW KEY | Decreases the width and height of the selected picture by 1%. |
CTRL+SHIFT+DOWN ARROW KEY | Decreases the width and height of the selected picture by 1%. |
CTRL+A | Selects all pictures in a worksheet. |
TAB | Selects the next picture in a worksheet. |
TAB+SHIFT | Selects the previous picture in a worksheet. |