Add-OfficeExcelImage
Embeds a file, HTTP image or reusable visual at a worksheet cell or range.
Syntax
Add-OfficeExcelImage
[-Address <String>]
[-AltText <String>]
[-Decorative]
[-Document <ExcelDocument>]
[-EndOffsetX <OfficeLength>]
[-EndOffsetY <OfficeLength>]
[-Height <OfficeLength>]
[-Name <String>]
[-NoLockAspectRatio]
[-OffsetX <OfficeLength>]
[-OffsetY <OfficeLength>]
[-PassThru]
[-Path] <String>
[-Placement <MoveAndSize| MoveOnly| FreeFloating>]
[-Rotation <Double>]
[-Scale <Double>]
[-Sheet <OfficeSheetSelector>]
[-Title <String>]
[-Width <OfficeLength>]
[<CommonParameters>]#PathAdd-OfficeExcelImage
[-Address <String>]
[-AltText <String>]
[-Decorative]
[-Document <ExcelDocument>]
[-EndOffsetX <OfficeLength>]
[-EndOffsetY <OfficeLength>]
[-Height <OfficeLength>]
[-Name <String>]
[-NoLockAspectRatio]
[-OffsetX <OfficeLength>]
[-OffsetY <OfficeLength>]
[-PassThru]
[-Placement <MoveAndSize| MoveOnly| FreeFloating>]
[-Rotation <Double>]
[-Scale <Double>]
[-Sheet <OfficeSheetSelector>]
[-Title <String>]
-Url <Uri>
[-Width <OfficeLength>]
[<CommonParameters>]#UrlAdd-OfficeExcelImage
[-Address <String>]
[-AltText <String>]
[-Decorative]
[-Document <ExcelDocument>]
[-EndOffsetX <OfficeLength>]
[-EndOffsetY <OfficeLength>]
[-Height <OfficeLength>]
[-Id <String>]
-InputObject <Object>
[-MaximumSvgElements <Int32>]
[-MaximumSvgViewportDimension <Double>]
[-MaximumSvgViewportPixelCount <Int64>]
[-Name <String>]
[-NoLockAspectRatio]
[-OffsetX <OfficeLength>]
[-OffsetY <OfficeLength>]
[-PassThru]
[-Placement <MoveAndSize| MoveOnly| FreeFloating>]
[-PointsPerPixel <Double>]
[-Rotation <Double>]
[-Scale <Double>]
[-Sheet <OfficeSheetSelector>]
[-SvgPolicy <PreserveVector| RasterizeWhenNeeded| RequireVector>]
[-Title <String>]
[-Width <OfficeLength>]
[<CommonParameters>]#VisualDescription
A cell uses a one-cell anchor; a range uses a two-cell anchor. Numbers mean points and unit suffixes are accepted. With no dimensions or Scale, file images retain their detected size. Range anchors determine their own size. URL downloads use the native network policy and cancellation token.
Examples
Place a logo at its natural size.
ExcelSheet 'Cover' { ExcelImage -Path ./logo.png -Address A1 -AltText 'Contoso' }Pin a reusable visual to the report header.
$visual | ExcelImage -Document $book -Sheet Summary -Address B2:G12 -Name HealthDownload and resize a status badge.
ExcelImage -Url https://status.example.com/badge.png -Address H1 -Width 4cmAdd a logo
New-OfficeExcel -Path .\Reports\Q3-Sales.xlsx {
ExcelSheet 'Cover' {
ExcelImage .\Assets\Logo.png -Address A1 -AltText 'Northwind Traders logo'
}
}Places the company logo at A1 of the cover sheet at its natural size.
Fit a site photo into a range
Open-OfficeExcel -Path .\Facilities\Inspection-Gdansk.xlsx {
ExcelSheet 'Findings' {
ExcelImage .\Photos\Gdansk-Roof-0412.jpg -Address D2:J20 -Placement MoveAndSize -AltText 'Roof drainage at the Gdansk warehouse'
}
}Stretches an inspection photo across D2:J20 so it moves and resizes with the cells.
Add an image from a URL
Open-OfficeExcel -Path .\Reports\Status.xlsx {
ExcelSheet 'Summary' {
ExcelImage -Url https://status.example.com/badge/production.png -Address H1 -Width 4cm -AltText 'Production status'
}
}Downloads a published status badge and places it at a fixed width on the summary sheet.
Parameters
- -Address String
- A1 cell or range; defaults to A1. Use B2:B2 for a two-cell anchor over one cell.
- -AltText String
- Accessible image description; omitted visual descriptions are retained.
- -Decorative SwitchParameter
- Clear accessible title and description and mark the image decorative.
- -Document ExcelDocument
- Workbook to modify outside the Excel DSL.
- -EndOffsetX OfficeLength
- Horizontal end-marker offset for a range anchor; numbers mean points.
- -EndOffsetY OfficeLength
- Vertical end-marker offset for a range anchor; numbers mean points.
- -Height OfficeLength
- Optional output height; numbers mean points and unit suffixes are accepted.
- -Name String
- Drawing name in Excel's selection pane.
- -NoLockAspectRatio SwitchParameter
- Allow interactive aspect-ratio changes in Excel; the default locks the ratio.
- -OffsetX OfficeLength
- Horizontal start-marker offset; numbers mean points.
- -OffsetY OfficeLength
- Vertical start-marker offset; numbers mean points.
- -PassThru SwitchParameter
- Return the native editable ExcelImage.
- -Path String
- Literal local image path.
- -Placement ExcelImagePlacement
- Movement and resizing behavior of a two-cell anchor.
- Possible values:
MoveAndSize,MoveOnly,FreeFloating - -Rotation Double
- Clockwise rotation in degrees.
- -Scale Double
- Positive percentage of the source size; exclusive with dimensions and range anchors.
- -Sheet OfficeSheetSelector
- Sheet name, one-based position or native worksheet belonging to Document.
- -Title String
- Optional title for an SVG file input.
- -Width OfficeLength
- Optional output width; numbers mean points and unit suffixes are accepted.
- -Url Uri
- HTTP or HTTPS image URI; local files use Path.
- -Id String
- Optional stable identifier for an SVG file input.
- -InputObject Object
- ChartForgeX artifact, OfficeVisualSource, prepared visual or SVG path.
- -MaximumSvgElements Int32
- Optional OfficeIMO SVG import element limit.
- -MaximumSvgViewportDimension Double
- Optional maximum SVG viewport width or height. Increase the safe default only for trusted input.
- -MaximumSvgViewportPixelCount Int64
- Optional maximum SVG viewport area in pixels. Increase the safe default only for trusted input.
- -PointsPerPixel Double
- Conversion factor from ChartForgeX pixels to Office points.
- -SvgPolicy OfficeVisualSvgPolicy
- SVG fidelity policy used by OfficeIMO.ChartForgeX.
- Possible values:
PreserveVector,RasterizeWhenNeeded,RequireVector
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.