Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/

Automate Excel Workbooks

Edit on GitHub

Build, inspect, validate, compare, repair, and publish workbook workflows from PowerShell. Includes examples and cmdlet links.

Excel is the largest PSWriteOffice family with 103 exported commands. It covers workbook creation and reading, sheet and range operations, formulas, styling, tables, charts, pivots, validation, comments, images, links, templates, dashboards, protection, accessibility, comparison, repair, streaming contracts, and direct range or chart image export.

Export rows in one line

Use the pipeline when the job is simply PowerShell objects to a worksheet:

$records | Export-OfficeExcel -Path '.\Revenue.xlsx' -Sheet 'Sales' -TableName 'Sales'

Use the object or DSL surface when you need several sheets, formulas, charts, pivots, or precise formatting.

Create a workbook from data

Use New-OfficeExcel with Add-OfficeExcelSheet, then add tables, formulas, charts, and report components inside each sheet context. The report DSL includes titles, paragraphs, sections, callouts, KPI rows, tables, legends, spacers, and dashboard charts for repeatable operational output.

$records = @(
    [pscustomobject]@{ Region = 'EMEA'; Revenue = 98000 }
    [pscustomobject]@{ Region = 'APAC'; Revenue = 143000 }
)

New-OfficeExcel -Path '.\Output\Revenue.xlsx' {
    Add-OfficeExcelSheet -Name 'Sales' {
        Add-OfficeExcelTable -InputObject $records -Name 'Sales'
        Add-OfficeExcelChart -Table 'Sales' -Address E2 -Type ColumnClustered -Title 'Revenue by region'
    }
}

Copy complete DSL recipes

  • Project tracker: table, validation list, conditional rules, chart, frozen header, print layout, and workbook index.
  • Budget dashboard: summary formulas and chart over a separate styled detail sheet.
  • Operational dashboard: the larger example with KPIs, pivots, sparklines, charts, links, comments, queries, and validation.

Other Excel workflows

The DSL cookbook shows how Excel composition differs from the Word, PowerPoint, PDF, and Markdown blocks that consume the same objects.

Task guides

Work with existing workbooks

The read surface can return used ranges, tables, named ranges, formulas, comments, validation, rich text, worksheet views, page breaks, pivots, summaries, preflight data, and streaming capabilities. Targeted commands update cells, rows, columns, styles, formulas, links, page setup, print settings, themes, worksheet visibility, active sheet, filters, and write reservations.

Validate before delivery

  • Test-OfficeDocument checks workbook integrity; New-OfficeExcelTestOptions selects capabilities and repair hints.
  • Import-OfficeExcel -WarningAction Stop surfaces runtime import warnings before downstream processing.
  • Test-OfficeDocument -Check Accessibility supports accessible-delivery gates.
  • Compare-OfficeDocument and Compare-OfficeExcelRange make change evidence explicit.
  • Repair-OfficeDocument applies deliberate workbook repairs and returns its native evidence with -PassThru.

Validation reports expose IsValid, Diagnostics, and NativeReports. Detailed inspection uses Get-OfficeDocumentInfo -Detailed; its native workbook snapshot is in Details.

Templates, joins, merges, sheet ordering, workbook copying, HTML review, and delimited import/export cover the surrounding pipeline. Search the command reference for OfficeExcel; use the Excel examples for complete workflows.

API used on this page

Example source