Skip to content

EvotecIT/PSWriteOffice

Repository files navigation

PSWriteOffice

Create and read Word, Excel, PowerPoint, Markdown, and CSV files from PowerShell.

PowerShell Gallery Version PowerShell Gallery Preview PowerShell Gallery Downloads PowerShell Gallery Platforms Test PowerShell Test .NET Libraries License

What PSWriteOffice Is

PSWriteOffice is a PowerShell-first layer over OfficeIMO.*.

  • OfficeIMO owns the file-format implementation and deep document behavior.
  • PSWriteOffice owns the cmdlets, DSL, packaging, examples, and PowerShell ergonomics.
  • The module is designed to stay thin, predictable, and easy to script across Windows, Linux, and macOS.

Current Coverage

Area Status Current direction
Word Mature Document generation, HTML conversion, fields, content controls, readers
Excel Advanced Tables, ranges, formulas, charts, comments, pivots, validation, page setup
PowerPoint Improving fast Slides, placeholders, layout edits, notes, inspection helpers
Markdown Solid Parse Markdown, build Markdown with a DSL, render HTML
CSV Solid Read documents/data and export objects to CSV

Install

Install-Module PSWriteOffice -Scope CurrentUser
Import-Module PSWriteOffice

Quick Start

Word

New-OfficeWord -Path .\Report.docx {
    WordSection {
        WordHeader { WordParagraph -Text 'Quarterly Report' -Style Heading2 }
        WordFooter { WordPageNumber }
        WordParagraph -Text 'Hello from PSWriteOffice.'
        WordList -Style Bulleted {
            WordListItem -Text 'Alpha'
            WordListItem -Text 'Beta'
        }
    }
}

Excel

New-OfficeExcel -Path .\Report.xlsx {
    ExcelSheet 'Data' {
        ExcelCell -Address 'A1' -Value 'Name'
        ExcelCell -Address 'B1' -Value 'Value'
        ExcelTable -Data $Data -TableName 'ReportData' -AutoFit
        ExcelValidationList -Range 'C2:C20' -Values 'New','In Progress','Done'
    }
}

PowerPoint

New-OfficePowerPoint -Path .\Deck.pptx {
    PptSlide {
        PptTitle -Title 'Status Update'
        PptTextBox -Text 'Generated with PSWriteOffice' -X 80 -Y 150 -Width 360 -Height 60
        PptBullets -Bullets 'Wins','Risks','Next Steps' -X 430 -Y 150 -Width 260 -Height 200
        PptNotes -Text 'Keep this under five minutes.'
    }
}

Markdown

New-OfficeMarkdown -Path .\README.md {
    MarkdownHeading -Level 1 -Text 'Report'
    MarkdownParagraph -Text 'Generated by PSWriteOffice.'
    MarkdownList -Items 'Alpha','Beta'
    MarkdownCode -Language 'powershell' -Content 'Get-Process'
}

CSV

$Data | ConvertTo-OfficeCsv -OutputPath .\export.csv
Get-OfficeCsvData -Path .\export.csv

Read And Inspect

PSWriteOffice also covers read-back and inspection workflows.

Get-OfficeWordParagraph -Path .\Report.docx | Select-Object -First 5
Get-OfficeExcelNamedRange -Path .\Report.xlsx
Get-OfficeExcelPivotTable -Path .\Report.xlsx
$ppt = Get-OfficePowerPoint -FilePath .\Deck.pptx
Get-OfficePowerPointSlide -Presentation $ppt
Get-OfficePowerPointSlideSummary -Presentation $ppt
Get-OfficePowerPointNotes -Presentation $ppt
Get-OfficePowerPointShape -Presentation $ppt -Index 0
Get-OfficeMarkdown -Path .\README.md
Get-OfficeCsv -Path .\export.csv

Documentation

Start with the curated docs:

Useful examples:

Dependency Model

PSWriteOffice should depend on OfficeIMO.*, not re-own lower-level library versioning unless it has a direct reason to.

  • OfficeIMO.Word
  • OfficeIMO.Excel
  • OfficeIMO.PowerPoint
  • OfficeIMO.Markdown
  • OfficeIMO.CSV
  • OfficeIMO.Word.Html

That keeps package ownership centralized and reduces version drift between the PowerShell layer and the document engine.

Build And Test

dotnet build .\Sources\PSWriteOffice.sln -c Debug
pwsh -NoLogo -NoProfile -File .\PSWriteOffice.Tests.ps1
pwsh -NoLogo -NoProfile -File .\Build\Validate-PackagedArtefact.ps1

Build and packaging are handled through:

  • Build/Manage-PSWriteOffice.ps1
  • PSPublishModule

The source tree stays development-friendly. Release artifacts are produced by the packaging pipeline.

Near-Term Direction

  • keep the OfficeIMO migration finished and thin
  • deepen Excel and PowerPoint coverage with real round-trip tests
  • add more read/inspection helpers where they improve scripting ergonomics
  • keep examples and docs aligned with the real tested surface

License

MIT

About

Experimental PowerShell Module to create and edit Microsoft Word, Microsoft Excel, and Microsoft PowerPoint documents without having Microsoft Office installed.

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors