# 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](/docs/pswriteoffice/object-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:

```powershell
$rows | Export-OfficeExcel -Path '.\Report.xlsx' -Sheet '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

Leave out the content block on `New-OfficeWord`, `New-OfficeExcel`, `New-OfficePowerPoint`, `New-OfficePdf` or `New-OfficeMarkdown` when loops and conditions need a live document. Add content through explicit `-Document`, `-Worksheet`, `-Document`, `-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 the matching `Open-Office*` 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. Use `Get-OfficeDocumentInfo -Detailed` for native snapshots, `Test-OfficeDocument` for document checks, `New-OfficeExcelTestOptions` for workbook capability checks, and `Get-OfficePdfDiagnostic` for PDF evidence.

Inspection-first workflows are appropriate for inventory, compliance gates, support diagnostics, and deciding which conversion route to use. `Get-OfficeDocumentCapability -Protection` lists supported protection operations; `-Conversion -From Word -To Pdf` lists conversion contracts.

## Normalize many formats

Use `New-OfficeDocumentReader` with `Read-OfficeDocument` when downstream code should not branch on every source format. Select chunks, hierarchy, structured data, tables, visuals, assets, or ingestion summaries with `-As`. `Get-OfficeDocumentInfo` handles detection and inspection.

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 `Convert-OfficeDocument` 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.

## Edit configuration and data files

Use `Open-OfficeYaml` when a person also maintains the file: the edit changes only the values you set and keeps comments, quoting, and layout. Use `Import-OfficeYaml`, `Import-OfficeToml`, or `Import-OfficeCsv` when the script only needs the data, and `Convert-OfficeDocument` to move data between JSON, YAML, TOML, XML, CSV, and Excel. See [Configuration files and data conversion](/docs/pswriteoffice/config-data-formats/).

## Continue

- [Command families](/docs/pswriteoffice/command-families/)
- [Pipeline, object, and DSL workflows](/docs/pswriteoffice/object-workflows/)
- [Automation patterns](/docs/pswriteoffice/automation-patterns/)
- [Troubleshooting and diagnostics](/docs/pswriteoffice/troubleshooting/)

<!-- PowerForge markdown source sha256:7E2AFEDC2C7BE148025043FB578A086F8A1646D4DEF564AA5477906FFB3B4A74; title=True -->

<!-- PowerForge markdown artifact sha256:BCB3DD8E0A80D1562089BA9BA3540C2CFD04C447CE2E22557DB39B1799EB3DC5 -->
