Usage Samples
This documentation starts with runnable examples, not API catalogs. The first sample project creates real Office files, saves them under examples/output/, then reads them back to verify the generated content.
Run it from the repository root:
dotnet run --project examples/UsageSamples/UsageSamples.csproj
Generated files:
examples/output/usage-workbook.xlsx
examples/output/usage-macro-preserve.xlsm
examples/output/usage-document.docx
examples/output/usage-presentation.pptx
Spreadsheet
usage-workbook.xlsx demonstrates the spreadsheet tasks most users need first:
- create an
.xlsxworkbook and sheet - write string and numeric cells
- apply fonts, fills, borders, alignment, and number formats
- merge a title range
- freeze header rows
- add an auto filter
- add a whole-number data validation
- add conditional formatting
- preserve rich text in a shared string
- enable sheet and workbook protection
- create a simple pivot table sheet
- read the workbook back and assert cell values
Source: examples/UsageSamples/Program.cs, CreateSpreadsheet.
Macro-Enabled Workbook
usage-macro-preserve.xlsm demonstrates:
- open an existing
.xlsmtemplate - edit workbook content
- save a new macro-enabled workbook
- compare
xl/vbaProject.binbefore and after to verify byte-for-byte VBA preservation
Source: examples/UsageSamples/Program.cs, CreateMacroWorkbookRoundTrip.
Word Document
usage-document.docx demonstrates:
- create paragraphs and runs
- set page size, margins, landscape orientation, and columns
- add default, first-page, and even-page headers and footers
- add PAGE, TOC, and MERGEFIELD fields
- apply bold text, font size, color, underline, and hyperlink metadata
- create a table
- embed an inline JPEG image
- read the document back and assert paragraphs, fields, page settings, table content, and image data
Source: examples/UsageSamples/Program.cs, CreateDocument.
PowerPoint Presentation
usage-presentation.pptx demonstrates:
- create slides
- add text boxes and formatted runs
- place and rotate an image
- create a simple table on a slide
- read the presentation back and assert slide, text, and table content
Source: examples/UsageSamples/Program.cs, CreatePresentation.
Documentation Scope
Phase 9 documentation is usage-only for now. Do not add class hierarchy pages or generated API reference pages until the practical guides have enough runnable coverage.