Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

ExcelImage

OfficeIMO.Excel

Namespace
OfficeIMO.Excel
Assembly
OfficeIMO.Excel
Source revision
273d35d5ba8a with working tree changes
Modifiers
sealed

Represents a worksheet image anchored in the drawing layer.

Inheritance

  • object
  • ExcelImage

Usage

Explore 16 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Methods

public ExcelImage Decorative() #

Marks the image as decorative: clears its alt text metadata and sets the Office decorative flag, so Excel and accessibility checkers skip it.

Returns

ExcelImage
public ExcelImage LockAspectRatio(bool locked = true) #

Controls whether Excel should keep the picture aspect ratio locked.

Parameters

locked bool = true optional

Returns

ExcelImage
public ExcelImage MoveTo(int row, int column, OfficeLength offsetX = default, OfficeLength offsetY = default) #

Moves the image to a one-cell anchor position and optionally applies length offsets.

Parameters

row int required
1-based target row.
column int required
1-based target column.
offsetX OfficeIMO.OfficeLength = default optional
Horizontal offset from the cell edge, as a document length.
offsetY OfficeIMO.OfficeLength = default optional
Vertical offset from the cell edge, as a document length.

Returns

ExcelImage
public ExcelImage SetAltText(string description, string? title = null) #

Sets image title and description metadata.

Parameters

description string required
title string? = null optional

Returns

ExcelImage
public ExcelImage SetCropRatio(double left, double top, double right, double bottom) #

Sets image crop ratios, where 0 means no crop and 1 means the full source dimension.

Parameters

left double required
top double required
right double required
bottom double required

Returns

ExcelImage
public ExcelImage SetFlip(bool horizontal, bool vertical) #

Sets image flip transforms.

Parameters

horizontal bool required
vertical bool required

Returns

ExcelImage
public ExcelImage SetRotation(double degrees) #

Sets clockwise image rotation in degrees.

Parameters

degrees double required
Clockwise rotation in degrees. Fractional values are supported by DrawingML.

Returns

ExcelImage
public ExcelImage SetSize(OfficeLength width, OfficeLength height) #

Sets the image size as a document length.

Parameters

width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required

Returns

ExcelImage
public ExcelImage SetSizePercent(double percent) #

Scales the image from its current size by the specified percentage.

Parameters

percent double required
Percentage of the current image size. For example, 20 means 20%.

Returns

ExcelImage
public ExcelImage SetTwoCellEndingMarker(int toRow, int toColumn, OfficeLength toOffsetX = default, OfficeLength toOffsetY = default) #

Sets the ending marker for a two-cell anchored image using 1-based worksheet marker coordinates.

Parameters

toRow int required
1-based ending row marker.
toColumn int required
1-based ending column marker.
toOffsetX OfficeIMO.OfficeLength = default optional
Horizontal offset from the ending marker column.
toOffsetY OfficeIMO.OfficeLength = default optional
Vertical offset from the ending marker row.

Returns

ExcelImage
public byte[] ToBytes() #

Returns a copy of the image bytes from the worksheet drawing relationship. An SVG picture returns its SVG.

Returns

byte[]
public bool TryGetAbsoluteAnchorBounds(out OfficeLength x, out OfficeLength y, out OfficeLength width, out OfficeLength height) #

Tries to read the image bounds when it is positioned by an absolute worksheet drawing anchor.

Parameters

x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required

Returns

bool

Properties

public string Name { get; set; } #

Gets or sets the image drawing name.

public string Title { get; set; } #

Gets or sets the image title metadata.

public int? TransparencyPercent { get; set; } #

Gets or sets DrawingML picture transparency from 0 through 100 percent. Null removes the explicit alpha transform.

public string Description { get; set; } #

Gets or sets the image alternative text description.

public bool IsAspectRatioLocked { get; } #

Gets whether Excel should keep the picture aspect ratio locked.

public int RowIndex { get; } #

Gets the 1-based row index where the image is anchored, when available.

public int ColumnIndex { get; } #

Gets the 1-based column index where the image is anchored, when available.

public OfficeLength Width { get; } #

Gets the image width as a document length from the drawing extent.

public OfficeLength Height { get; } #

Gets the image height as a document length from the drawing extent.

public OfficeLength OffsetX { get; } #

Gets the image horizontal offset from the anchor cell origin as a document length.

public OfficeLength OffsetY { get; } #

Gets the image vertical offset from the anchor cell origin as a document length.

public bool HasTwoCellAnchor { get; } #

Gets whether the image is positioned with a two-cell drawing anchor.

public bool HasAbsoluteAnchor { get; } #

Gets whether the image is positioned with an absolute drawing anchor.

public int? ToRowIndex { get; } #

Gets the 1-based ending row index for two-cell anchored images, when available.

public int? ToColumnIndex { get; } #

Gets the 1-based ending column index for two-cell anchored images, when available.

public OfficeLength ToOffsetX { get; } #

Gets the horizontal offset from the two-cell ending marker column as a document length.

public OfficeLength ToOffsetY { get; } #

Gets the vertical offset from the two-cell ending marker row as a document length.

public double CropLeftRatio { get; } #

Gets the left crop ratio authored on the image, where 0 means no crop and 1 means the full width.

public double CropTopRatio { get; } #

Gets the top crop ratio authored on the image, where 0 means no crop and 1 means the full height.

public double CropRightRatio { get; } #

Gets the right crop ratio authored on the image, where 0 means no crop and 1 means the full width.

public double CropBottomRatio { get; } #

Gets the bottom crop ratio authored on the image, where 0 means no crop and 1 means the full height.

public double RotationDegrees { get; set; } #

Gets or sets clockwise image rotation in degrees.

public bool FlipHorizontal { get; } #

Gets whether the image has an authored horizontal flip transform.

public bool FlipVertical { get; } #

Gets whether the image has an authored vertical flip transform.

public int DrawingOrder { get; } #

Gets this image anchor's zero-based order in the worksheet drawing layer.

public string ContentType { get; } #

Gets the image content type, such as image/png or image/jpeg. An SVG picture reports its SVG, not the PNG fallback.

public bool IsDecorative { get; } #

Gets whether the image is marked decorative, so screen readers and accessibility checks skip it.

public Uri? HyperlinkUri { get; set; } #

Gets or sets the picture's external hyperlink target. Null removes the click link. Targets are stored in the workbook and are never opened by OfficeIMO.