Project

PSWriteOffice

PSWriteOffice is an open-source PowerShell and .NET project with packages, release history, and technical documentation.

Stars159
Forks14
Open issues0
PowerShell Gallery downloads158661
Releasev3.0.5
Language: C# Updated: 2026-08-29T07:04:31.0000000+00:00

Documentation

Choose a PSWriteOffice Workflow

Decide between authoring, editing, inspection, conversion, and normalized Reader extraction. Includes examples and cmdlet links.

PSWriteOffice exposes several paths that can reach the same file format. Choosing the path by outcome keeps scripts smaller and makes failure handling clearer. See pipeline, object, and DSL workflows for copyable examples of each style.

Export rows directly

Use the pipeline for a simple data export. It is the shortest route from PowerShell objects, database results, or API responses to a workbook:

$rows | Export-OfficeExcel -Path '.\Report.xlsx' -WorksheetName 'Data' -TableName 'Data'

Move to the object or DSL surface only when the output needs more structure.

Create a new artifact

Use the document DSL when the script owns the output from the beginning. New-OfficeWord, New-OfficeExcel, New-OfficePowerPoint, New-OfficePdf, and New-OfficeVisio accept script blocks that describe the document. The outer command owns creation and final save; nested commands add content to the active document context.

This path works well for scheduled reports, build artifacts, exports, invoices, runbooks, and operational dashboards.

Build incrementally with document objects

Use New-OfficeWord, New-OfficeExcel, New-OfficePowerPoint, or New-OfficeMarkdown with -NoSave when normal loops and conditions need a live target. Add content through explicit -Document, -Worksheet, -Presentation, -Slide, or pipeline targets, then save once. This is also the natural migration path for scripts that previously held a PSWriteWord or PSWriteExcel document variable.

Load and change an existing file

Use a Get-* or import command to open the document, target specific content with Find-* or Get-*, apply Set-*, Update-*, Add-*, or Remove-* operations, and finish with the matching Save-* command.

Keep mutation explicit. A useful script shape is:

  1. inspect the input and collect diagnostics;
  2. decide whether the requested change is safe;
  3. apply a bounded set of changes;
  4. save to a new path during validation;
  5. compare or reopen the result.

Inspect without changing

Use inspection and preflight commands when the job needs evidence rather than a rewritten file. Examples include Get-OfficeWordStatistics, Get-OfficeExcelPreflight, Get-OfficePowerPointInspection, Get-OfficePdfDiagnostic, Get-OfficeVisioInfo, and the Reader result commands.

Inspection-first workflows are appropriate for inventory, compliance gates, support diagnostics, and deciding which conversion route to use.

Normalize many formats

Use New-OfficeDocumentReader and the Get-OfficeDocument* commands when downstream code should not branch on every source format. Reader exposes normalized documents, chunks, hierarchy, structured data, tables, visuals, assets, detections, and ingest results through one family of commands.

Choose the format-specific family instead when the script must edit native features that the normalized model intentionally does not preserve.

Convert and review

Use focused converters when the destination format is the outcome. HTML review commands are useful for browser-based review; Markdown is useful for source control and text pipelines; PDF is useful for fixed-layout delivery. Conversion can be loss-aware rather than lossless, so inspect diagnostics for complex documents and retain the source artifact.

Continue