[]
        
(Showing Draft Content)

C1.C1Excel.XLPictureShape.-ctor

XLPictureShape Constructor

XLPictureShape(Image, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(Image img, int x, int y)
Public Sub New(img As Image, x As Integer, y As Integer)
Parameters
Type Name Description
Image img

The image contained in the new XLPictureShape.

int x

The horizontal position of the new shape with respect to the cell, in twips.

int y

The vertical position of the new shape with respect to the cell, in twips.

Examples

The code below adds an image to a cell. The image is rendered in its original size, and is indented from the top left corner of the cell by 30 twips:

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(image, 30, 30);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(Image, int, int, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(Image img, int x, int y, int width, int height)
Public Sub New(img As Image, x As Integer, y As Integer, width As Integer, height As Integer)
Parameters
Type Name Description
Image img

The image contained in the new XLPictureShape.

int x

The horizontal position of the image with respect to the cell, in twips.

int y

The vertical position of the image with respect to the cell, in twips.

int width

The width of the image, in twips.

int height

The height of the image, in twips.

Examples

The code below adds an image to a cell. The image is drawn within a rectangle centered on a cell with a 60 twip edge around it:

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// calculate cell size to align picture
Rectangle rc = new Rectangle(0, 0
    sheet.Columns[col].Width, 
    sheet.Rows[row].Height);

// add 60 twip edge
rc.Inflate(-60, -60);

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(image, 
    rc.X, rc.Y, rc.Width, rc.Height);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(Image, Rectangle)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(Image img, Rectangle rc)
Public Sub New(img As Image, rc As Rectangle)
Parameters
Type Name Description
Image img

The image contained in the new XLPictureShape.

Rectangle rc

The rectangle that specifies the image size and position with respect to the cell, in twips.

Examples

The code below adds an image to a cell. The image is drawn within a rectangle centered on a cell with a 60 twip edge around it:

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// calculate cell size to align picture
Rectangle rc = new Rectangle(0, 0
    sheet.Columns[col].Width, 
    sheet.Rows[row].Height);

// add 60 twip edge
rc.Inflate(-60, -60);

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(image, rc);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(Image)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(Image img)
Public Sub New(img As Image)
Parameters
Type Name Description
Image img

The image contained in the new XLPictureShape.

XLPictureShape(Image, Size, ContentAlignment, ImageScaling)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(Image img, Size cellSize, ContentAlignment align, ImageScaling scale)
Public Sub New(img As Image, cellSize As Size, align As ContentAlignment, scale As ImageScaling)
Parameters
Type Name Description
Image img

The Image contained in the new XLPictureShape.

Size cellSize

The size of the cell that will contain the image, in pixels (used for aligning the image).

ContentAlignment align

A ContentAlignment value that specifies the position of the image in the cell.

ImageScaling scale

An ImageScaling value that specifies the image scaling within the cell.

Remarks

This constructor automatically calculates the image size, position, and clipping based on the cell and image sizes and on the given alignment and scaling parameters.

Examples

The code below adds an image to a cell. The image is centered within the cell and scaled to fill the cell while preserving its aspect ratio.

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// calculate cell size to align picture
Size cellSize = new Size(
    sheet.Columns[col].Width, 
    sheet.Rows[row].Height);

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(
    image,
    cellSize,
    ContentAlignment.MiddleCenter,
    ImageScaling.Scale);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(XLSheet, Image, int, int, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(XLSheet sheet, Image img, int x, int y, int width, int height)
Public Sub New(sheet As XLSheet, img As Image, x As Integer, y As Integer, width As Integer, height As Integer)
Parameters
Type Name Description
XLSheet sheet

XLSheet object that owns the new shape.

Image img

The image contained in the new XLPictureShape.

int x

The horizontal position of the image with respect to the sheet, in twips.

int y

The vertical position of the image with respect to the sheet, in twips.

int width

The width of the image, in twips.

int height

The height of the image, in twips.

XLPictureShape(C1Bitmap, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, int x, int y)
Public Sub New(bmp As C1Bitmap, x As Integer, y As Integer)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

int x

The horizontal position of the new shape with respect to the cell, in twips.

int y

The vertical position of the new shape with respect to the cell, in twips.

XLPictureShape(C1Bitmap, int, int, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, int x, int y, int width, int height)
Public Sub New(bmp As C1Bitmap, x As Integer, y As Integer, width As Integer, height As Integer)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

int x

The horizontal position of the image with respect to the cell, in twips.

int y

The vertical position of the image with respect to the cell, in twips.

int width

The width of the image, in twips.

int height

The height of the image, in twips.

XLPictureShape(C1Bitmap, RectangleF)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, RectangleF rc)
Public Sub New(bmp As C1Bitmap, rc As RectangleF)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

RectangleF rc

The rectangle that specifies the image size and position with respect to the cell, in twips.

XLPictureShape(C1Bitmap)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp)
Public Sub New(bmp As C1Bitmap)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

XLPictureShape(C1Bitmap, Size, ContentAlignment, ImageScaling)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, Size cellSize, ContentAlignment align, ImageScaling scale)
Public Sub New(bmp As C1Bitmap, cellSize As Size, align As ContentAlignment, scale As ImageScaling)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

Size cellSize

The size of the cell that will contain the image, in pixels (used for aligning the image).

ContentAlignment align

A ContentAlignment value that specifies the position of the image in the cell.

ImageScaling scale

An ImageScaling value that specifies the image scaling within the cell.

Remarks

This constructor automatically calculates the image size, position, and clipping based on the cell and image sizes and on the given alignment and scaling parameters.

XLPictureShape(XLSheet, C1Bitmap, int, int, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(XLSheet sheet, C1Bitmap bmp, int x, int y, int width, int height)
Public Sub New(sheet As XLSheet, bmp As C1Bitmap, x As Integer, y As Integer, width As Integer, height As Integer)
Parameters
Type Name Description
XLSheet sheet

XLSheet object that owns the new shape.

C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

int x

The horizontal position of the image with respect to the sheet, in twips.

int y

The vertical position of the image with respect to the sheet, in twips.

int width

The width of the image, in twips.

int height

The height of the image, in twips.