Table of Contents

Class ExcelDrawing

Namespace
OfficeOpenXml.Drawing
Assembly
EPPlus.dll

Base class for drawings. Drawings are Charts, Shapes and Pictures.

public class ExcelDrawing : XmlHelper, IDisposable
Inheritance
ExcelDrawing
Implements
Derived
Inherited Members

Fields

EMU_PER_CM

The ratio between EMU and centimeters

public const int EMU_PER_CM = 360000

Field Value

int

EMU_PER_MM

The ratio between EMU and milimeters

public const int EMU_PER_MM = 3600000

Field Value

int

EMU_PER_PICA

The ratio between EMU and pica

public const int EMU_PER_PICA = 152400

Field Value

int

EMU_PER_PIXEL

The ratio between EMU and Pixels

public const int EMU_PER_PIXEL = 9525

Field Value

int

EMU_PER_POINT

The ratio between EMU and Points

public const int EMU_PER_POINT = 12700

Field Value

int

EMU_PER_US_INCH

The ratio between EMU and US Inches

public const int EMU_PER_US_INCH = 914400

Field Value

int

Properties

As

Provides access to type conversion for all top-level drawing classes.

public ExcelDrawingAsType As { get; }

Property Value

ExcelDrawingAsType

CellAnchor

How the drawing is anchored to the cells. This effect how the drawing will be resize ChangeCellAnchor(eEditAs, int, int, int, int)

public eEditAs CellAnchor { get; protected set; }

Property Value

eEditAs

Description

A description of the drawing object

public string Description { get; set; }

Property Value

string

DrawingType

The type of drawing

public virtual eDrawingType DrawingType { get; }

Property Value

eDrawingType

EditAs

How Excel resize drawings when the column width is changed within Excel.

public eEditAs EditAs { get; set; }

Property Value

eEditAs

From

Top Left position, if the shape is of the one- or two- cell anchor type Otherwise this propery is set to null

public ExcelPosition From { get; }

Property Value

ExcelPosition

Hyperlink

public Uri Hyperlink { get; set; }

Property Value

Uri

Locked

Lock drawing

public virtual bool Locked { get; set; }

Property Value

bool

Name

The name of the drawing object

public virtual string Name { get; set; }

Property Value

string

ParentGroup

If the drawing is grouped this property contains the Group drawing containing the group. Otherwise this property is null

public ExcelGroupShape ParentGroup { get; }

Property Value

ExcelGroupShape

Position

Top Left position, if the shape is of the absolute anchor type

public ExcelDrawingCoordinate Position { get; }

Property Value

ExcelDrawingCoordinate

Print

Print drawing with sheet

public virtual bool Print { get; set; }

Property Value

bool

Size

The extent of the shape, if the shape is of the one- or absolute- anchor type. Otherwise this propery is set to null

public ExcelDrawingSize Size { get; }

Property Value

ExcelDrawingSize

To

Bottom right position

public ExcelPosition To { get; }

Property Value

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.

public void AdjustPositionAndSize()

BringToFront()

Brings the drawing to the front of any overlapping drawings.

public void BringToFront()

ChangeCellAnchor(eEditAs)

This will change the cell anchor type without modifiying the position and size.

public void ChangeCellAnchor(eEditAs type)

Parameters

type eEditAs

The cell anchor type to change to

ChangeCellAnchor(eEditAs, int, int, int, int)

This will change the cell anchor type, move and resize the drawing.

public void ChangeCellAnchor(eEditAs type, int PixelTop, int PixelLeft, int width, int height)

Parameters

type eEditAs

The cell anchor type to change to

PixelTop int

The topmost pixel

PixelLeft int

The leftmost pixel

width int

The width in pixels

height int

The height in pixels

Copy(ExcelWorksheet, int, int, int, int)

public void Copy(ExcelWorksheet worksheet, int row, int col, int rowOffset = -2147483648, int colOffset = -2147483648)

Parameters

worksheet ExcelWorksheet
row int
col int
rowOffset int
colOffset int

Dispose()

Dispose the object

public virtual void Dispose()

Group(params ExcelDrawing[])

Group the drawing together with a list of other drawings. UnGroup(bool) ParentGroup

public ExcelGroupShape Group(params ExcelDrawing[] drawing)

Parameters

drawing ExcelDrawing[]

The drawings to group

Returns

ExcelGroupShape

The group shape

SendToBack()

Sends the drawing to the back of any overlapping drawings.

public void SendToBack()

SetPosition(int, int)

Set the top left corner of a drawing. Note that resizing columns / rows after using this function will effect the position of the drawing

public void SetPosition(int PixelTop, int PixelLeft)

Parameters

PixelTop int

Top pixel

PixelLeft int

Left pixel

SetPosition(int, int, int, int)

Set the top left corner of a drawing. Note that resizing columns / rows after using this function will effect the position of the drawing

public void SetPosition(int Row, int RowOffsetPixels, int Column, int ColumnOffsetPixels)

Parameters

Row int

Start row - 0-based index.

RowOffsetPixels int

Offset in pixels

Column int

Start Column - 0-based index.

ColumnOffsetPixels int

Offset in pixels

SetSize(int)

Set size in Percent. Note that resizing columns / rows after using this function will effect the size of the drawing

public virtual void SetSize(int Percent)

Parameters

Percent int

SetSize(int, int)

Set size in pixels Note that resizing columns / rows after using this function will effect the size of the drawing

public void SetSize(int PixelWidth, int PixelHeight)

Parameters

PixelWidth int

Width in pixels

PixelHeight int

Height in pixels

UnGroup(bool)

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.

public void UnGroup(bool ungroupThisItemOnly = true)

Parameters

ungroupThisItemOnly bool

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.