Skip to main content
OfficeIMO Docs Search documentation/

Migrate from PSWriteExcel to PSWriteOffice

Edit on GitHub

Replace archived PSWriteExcel scripts with maintained PSWriteOffice commands for XLSX creation, import, formulas, charts, and validation.

PSWriteExcel is archived and replaced by PSWriteOffice. New scripts should use the OfficeExcel command family over OfficeIMO.Excel.

The current Excel DSL is more explicit than the legacy pipeline helpers. A simple ConvertTo-Excel export normally becomes New-OfficeExcel with a sheet and table block; scripts that update existing workbooks should use Get-OfficeExcel, targeted setters, and Save-OfficeExcel.

Common command replacements

PSWriteExcelPSWriteOfficeMigration note
New-ExcelDocumentNew-OfficeExcelUse -NoSave only when the document must remain open for later operations.
Get-ExcelDocumentGet-OfficeExcelInspect worksheets, ranges, tables, formulas, comments, and workbook metadata with targeted commands.
Add-ExcelWorkSheetAdd-OfficeExcelSheetAdd it inside a New-OfficeExcel or active workbook context.
Add-ExcelWorkSheetCellSet-OfficeExcelCellAddress cells by A1 address or row and column.
Add-ExcelWorksheetDataAdd-OfficeExcelTable or Add-OfficeExcelDataSetChoose a table for object rows or the dataset command for System.Data.DataSet.
ConvertTo-ExcelNew-OfficeExcel plus Add-OfficeExcelTableThe replacement is a document workflow, not a parameter-compatible pipeline alias.
ConvertFrom-ExcelImport-OfficeExcelSelect the sheet and range required by the consuming script.
Set-ExcelWorkSheetAutoFitInvoke-OfficeExcelAutoFitApply it to the intended sheet or range.
Set-ExcelWorkSheetFreezePaneSet-OfficeExcelFreezeRecheck pane coordinates after migration.
Set-ExcelWorkSheetAutoFilterSet-OfficeExcelAutoFilterTables can also own their filtering behavior.
Save-ExcelDocumentSave-OfficeExcelNew-OfficeExcel saves automatically unless -NoSave is used.

Before: PSWriteExcel

Get-Process |
    Select-Object Name, Id, CPU |
    ConvertTo-Excel -Path '.\Output\Processes.xlsx' -WorkSheetName 'Processes' -AutoFilter

After: PSWriteOffice

$processes = Get-Process |
    Select-Object Name, Id, CPU

New-OfficeExcel -Path '.\Output\Processes.xlsx' {
    Add-OfficeExcelSheet -Name 'Processes' {
        Add-OfficeExcelTable -InputObject $processes -TableName 'Processes' -AutoFit
    }
}

To read workbook data:

$rows = Import-OfficeExcel -Path '.\Output\Processes.xlsx' -WorksheetName 'Processes'
$rows | Where-Object CPU -gt 10

Validate before replacing the old job

  • compare property-to-column mapping, null values, dates, number formats, and culture-sensitive values;
  • recalculate or mark formulas for recalculation deliberately with Save-OfficeExcel options;
  • verify filters, tables, styles, freeze panes, charts, and print settings;
  • use Test-OfficeExcelWorkbook and, when relevant, Test-OfficeExcelAccessibility;
  • benchmark representative large exports rather than assuming either object pipeline has the same memory profile.

See Excel automation and the generated PowerShell command reference for current syntax.