Class ExcelDrawing
Base class for drawings. Drawings are Charts, Shapes and Pictures.
Inheritance
Implements
Inherited Members
Namespace: OfficeOpenXml.Drawing
Assembly: EPPlus.dll
Syntax
public class ExcelDrawing : XmlHelper, IDisposable, IPictureContainer
Fields
_doNotAdjust
Declaration
protected bool _doNotAdjust
Field Value
| Type | Description |
|---|---|
| System.Boolean |
EMU_PER_CM
Declaration
public const int EMU_PER_CM = 360000
Field Value
| Type | Description |
|---|---|
| System.Int32 |
EMU_PER_MM
Declaration
public const int EMU_PER_MM = 3600000
Field Value
| Type | Description |
|---|---|
| System.Int32 |
EMU_PER_PICA
Declaration
public const int EMU_PER_PICA = 152400
Field Value
| Type | Description |
|---|---|
| System.Int32 |
EMU_PER_PIXEL
Ratio between EMU and Pixels
Declaration
public const int EMU_PER_PIXEL = 9525
Field Value
| Type | Description |
|---|---|
| System.Int32 |
EMU_PER_POINT
Ratio between EMU and Points
Declaration
public const int EMU_PER_POINT = 12700
Field Value
| Type | Description |
|---|---|
| System.Int32 |
EMU_PER_US_INCH
Declaration
public const int EMU_PER_US_INCH = 914400
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Properties
As
Provides access to type conversion for all top-level drawing classes.
Declaration
public ExcelDrawingAsType As { get; }
Property Value
| Type | Description |
|---|---|
| ExcelDrawingAsType |
CellAnchor
How the drawing is anchored to the cells. This effect how the drawing will be resize ChangeCellAnchor(eEditAs, Int32, Int32, Int32, Int32)
Declaration
public eEditAs CellAnchor { get; protected set; }
Property Value
| Type | Description |
|---|---|
| eEditAs |
Description
A description of the drawing object
Declaration
public string Description { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
DrawingType
The type of drawing
Declaration
public virtual eDrawingType DrawingType { get; }
Property Value
| Type | Description |
|---|---|
| eDrawingType |
EditAs
How Excel resize drawings when the column width is changed within Excel.
Declaration
public eEditAs EditAs { get; set; }
Property Value
| Type | Description |
|---|---|
| eEditAs |
From
Top Left position, if the shape is of the one- or two- cell anchor type Otherwise this propery is set to null
Declaration
public ExcelPosition From { get; }
Property Value
| Type | Description |
|---|---|
| ExcelPosition |
Hyperlink
Hyperlink
Declaration
public Uri Hyperlink { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Uri |
Locked
Lock drawing
Declaration
public virtual bool Locked { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Name
The name of the drawing object
Declaration
public virtual string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
ParentGroup
If the drawing is grouped this property contains the Group drawing containing the group. Otherwise this property is null
Declaration
public ExcelGroupShape ParentGroup { get; }
Property Value
| Type | Description |
|---|---|
| ExcelGroupShape |
Position
Top Left position, if the shape is of the absolute anchor type
Declaration
public ExcelDrawingCoordinate Position { get; }
Property Value
| Type | Description |
|---|---|
| ExcelDrawingCoordinate |
Print drawing with sheet
Declaration
public virtual bool Print { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Size
The extent of the shape, if the shape is of the one- or absolute- anchor type. Otherwise this propery is set to null
Declaration
public ExcelDrawingSize Size { get; }
Property Value
| Type | Description |
|---|---|
| ExcelDrawingSize |
To
Bottom right position
Declaration
public ExcelPosition To { get; }
Property Value
| Type | Description |
|---|---|
| ExcelPosition |
Methods
AdjustPositionAndSize()
Will adjust the position and size of the drawing according to changes in font of rows and to the Normal style. This method will be called before save, so use it only if you need the coordinates of the drawing.
Declaration
public void AdjustPositionAndSize()
BringToFront()
Brings the drawing to the front of any overlapping drawings.
Declaration
public void BringToFront()
ChangeCellAnchor(eEditAs)
This will change the cell anchor type without modifiying the position and size.
Declaration
public void ChangeCellAnchor(eEditAs type)
Parameters
| Type | Name | Description |
|---|---|---|
| eEditAs | type | The cell anchor type to change to |
ChangeCellAnchor(eEditAs, Int32, Int32, Int32, Int32)
This will change the cell anchor type, move and resize the drawing.
Declaration
public void ChangeCellAnchor(eEditAs type, int PixelTop, int PixelLeft, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| eEditAs | type | The cell anchor type to change to |
| System.Int32 | PixelTop | The topmost pixel |
| System.Int32 | PixelLeft | The leftmost pixel |
| System.Int32 | width | The width in pixels |
| System.Int32 | height | The height in pixels |
CreateClientData()
Declaration
protected XmlElement CreateClientData()
Returns
| Type | Description |
|---|---|
| System.Xml.XmlElement |
CreateShapeNode()
Declaration
protected XmlElement CreateShapeNode()
Returns
| Type | Description |
|---|---|
| System.Xml.XmlElement |
Dispose()
Dispose the object
Declaration
public virtual void Dispose()
Group(ExcelDrawing[])
Group the drawing together with a list of other drawings. UnGroup(Boolean) ParentGroup
Declaration
public ExcelGroupShape Group(params ExcelDrawing[] drawing)
Parameters
| Type | Name | Description |
|---|---|---|
| ExcelDrawing[] | drawing | The drawings to group |
Returns
| Type | Description |
|---|---|
| ExcelGroupShape | The group shape |
SendToBack()
Sends the drawing to the back of any overlapping drawings.
Declaration
public void SendToBack()
SetPosition(Int32, Int32)
Set the top left corner of a drawing. Note that resizing columns / rows after using this function will effect the position of the drawing
Declaration
public void SetPosition(int PixelTop, int PixelLeft)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | PixelTop | Top pixel |
| System.Int32 | PixelLeft | Left pixel |
SetPosition(Int32, Int32, Int32, Int32)
Set the top left corner of a drawing. Note that resizing columns / rows after using this function will effect the position of the drawing
Declaration
public void SetPosition(int Row, int RowOffsetPixels, int Column, int ColumnOffsetPixels)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | Row | Start row - 0-based index. |
| System.Int32 | RowOffsetPixels | Offset in pixels |
| System.Int32 | Column | Start Column - 0-based index. |
| System.Int32 | ColumnOffsetPixels | Offset in pixels |
SetSize(Int32)
Set size in Percent. Note that resizing columns / rows after using this function will effect the size of the drawing
Declaration
public virtual void SetSize(int Percent)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | Percent |
SetSize(Int32, Int32)
Set size in pixels Note that resizing columns / rows after using this function will effect the size of the drawing
Declaration
public void SetSize(int PixelWidth, int PixelHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | PixelWidth | Width in pixels |
| System.Int32 | PixelHeight | Height in pixels |
UnGroup(Boolean)
Will ungroup this drawing or the entire group, if this drawing is grouped together with other drawings. If this drawings is not grouped an InvalidOperationException will be returned.
Declaration
public void UnGroup(bool ungroupThisItemOnly = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | ungroupThisItemOnly | If true this drawing will be removed from the group. If it is false, the whole group will be disbanded. If true only this drawing will be removed. |