Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b46ccf3
Update NugetReadme and gitattributes configuration
stesee Oct 12, 2025
2a4ffd8
Merge pull request #160 from Codeuctivity/NugetReadme
stesee Oct 12, 2025
3154e15
Bump System.Configuration.ConfigurationManager from 9.0.9 to 9.0.10
dependabot[bot] Oct 15, 2025
91ec966
Merge pull request #161 from Codeuctivity/dependabot/nuget/OpenXmlPow…
stesee Oct 15, 2025
414ddb6
Initial plan
Copilot Oct 24, 2025
5bbbb41
Add .NET 10 support to all projects and CI workflow
Copilot Oct 24, 2025
56e330d
Bump actions/upload-artifact from 4 to 5
dependabot[bot] Oct 27, 2025
f71099d
Merge pull request #164 from Codeuctivity/dependabot/github_actions/a…
stesee Oct 28, 2025
eaf04b9
Merge pull request #162 from Codeuctivity/copilot/update-targetframew…
stesee Oct 29, 2025
5871cd2
Bump actions/setup-dotnet from 4 to 5
dependabot[bot] Sep 8, 2025
45894fb
Bump actions/stale from 9 to 10
dependabot[bot] Sep 8, 2025
13a1714
Bump System.Configuration.ConfigurationManager from 9.0.8 to 9.0.9
dependabot[bot] Sep 10, 2025
a1d00b2
Add expected diff on windows (probably msising fonts, got no ms offic…
stesee Sep 20, 2025
892eb88
Add expected diff known to be found on github actions runners
stesee Sep 20, 2025
1a1ae43
Bump SkiaSharp from 3.119.0 to 3.119.1
dependabot[bot] Sep 24, 2025
f68e66d
Bump SkiaSharp.NativeAssets.Linux.NoDependencies from 3.119.0 to 3.119.1
dependabot[bot] Sep 24, 2025
d6744b1
Bump SkiaSharp.NativeAssets.Linux.NoDependencies from 3.119.0 to 3.119.1
dependabot[bot] Oct 7, 2025
3d90924
Update dependencies and add new test diff images
stesee Oct 10, 2025
a317e98
Replace SixLabors.Fonts with SkiaSharp for font metrics
stesee Oct 10, 2025
45bb155
Update OpenXML SDK to 3.3.0 and adjust tests
stesee Oct 10, 2025
29c9106
Remove pull_request trigger from dotnet workflow
stesee Oct 10, 2025
e46a9ae
Update OpenXmlPowerTools/FontMetric/FontStyle.cs
stesee Oct 10, 2025
e8b88a5
Update OpenXmlPowerTools/FontMetric/FontStyle.cs
stesee Oct 10, 2025
c52679a
added acceptable diff
stesee Oct 10, 2025
50e1364
Update NugetReadme and gitattributes configuration
stesee Oct 12, 2025
727d327
Bump System.Configuration.ConfigurationManager from 9.0.9 to 9.0.10
dependabot[bot] Oct 15, 2025
bf7fc36
Bump actions/upload-artifact from 4 to 5
dependabot[bot] Oct 27, 2025
b4500d6
Add .NET 10 support to all projects and CI workflow
Copilot Oct 24, 2025
21d1b39
Merge branch 'Codeuctivity:main' into main
mapo80 Nov 5, 2025
bff8f85
- DocumentAssembler now fully supports <Image> placeholders with expl…
politom-linksmt Nov 5, 2025
107140f
Bump System.Configuration.ConfigurationManager from 9.0.10 to 10.0.0
dependabot[bot] Nov 12, 2025
5c13cc0
Merge pull request #167 from Codeuctivity/dependabot/nuget/OpenXmlPow…
stesee Nov 14, 2025
8a3c668
Update CLA workflow and test dependencies
stesee Nov 15, 2025
114a427
Merge pull request #168 from Codeuctivity/TestDependencies
stesee Nov 15, 2025
833cf0b
Merge pull request #165 from mapo80/main
stesee Nov 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
*.csproj text eol=crlf
# Ignore line ending changes in csproj files to prevent VS Code auto-formatting issues
*.csproj text=auto

# Denote all files that are truly binary and should not be modified.
*.png binary
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
path-to-document: "https://github.com/Codeuctivity/OpenXmlPowerTools/blob/main/cla.md" # e.g. a CLA or a DCO document
# branch should not be protected
branch: "cla"
allowlist: dependabot[bot],stesee
allowlist: dependabot[bot],stesee,github-copilot[bot]

#below are the optional inputs - If the optional inputs are not given, then default values will be taken
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ runner.workspace }}/OpenXmlPowerTools/TestResult/test_results.trx"
- name: Publish Unit Test Results
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
if: failure()
with:
name: TestResult
Expand All @@ -40,7 +42,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down Expand Up @@ -68,7 +72,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ TestResults/
.idea/
_ReSharper.Caches/

TestResult/
TestResult/
ExampleOutput*
78 changes: 78 additions & 0 deletions DOCUMENT_ASSEMBLER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# OpenXmlPowerTools

OpenXmlPowerTools provides guidance and example code for programming with Open XML Documents (DOCX, XLSX, and PPTX). It is based on, and extends the functionality of the Open XML SDK.

## Document Assembler

The `DocumentAssembler` module is a powerful tool for generating documents from templates and data. It allows you to create `.docx` files with dynamic content, such as tables, conditional sections, and repeating elements, based on data from an XML file.

### Key Features

* **Template-Based Document Generation**: Create documents from Word templates (`.docx`) and populate them with data from XML files.
* **Content Replacement**: Use simple placeholders in your template to insert data from your XML file.
* **Dynamic Tables**: Automatically generate tables in your document based on data from your XML file.
* **Conditional Content**: Include or exclude parts of your document based on conditions in your data.
* **Repeating Content**: Repeat sections of your document for each item in a collection in your data.
* **Error Handling**: The `DocumentAssembler` will report errors in the generated document if it encounters any issues with your template or data.

### How it Works

The `DocumentAssembler` works by processing a Word document that contains special markup in content controls or in paragraphs. This markup defines how the document should be assembled based on the provided XML data.

The process is as follows:

1. **Create a Template**: Start with a regular Word document (`.docx`).
2. **Add Placeholders**: Use content controls or special syntax in paragraphs to define placeholders for your data.
3. **Provide Data**: Create an XML file that contains the data you want to insert into the document.
4. **Assemble the Document**: Use the `DocumentAssembler.AssembleDocument` method to merge the template and data, producing a new Word document.

### Template Syntax

The template syntax uses XML elements within content controls or as text in the format `<#ElementName ... #>`.

#### Content Replacement

To replace a placeholder with a value from your XML data, you can use the `Content` element. The `Select` attribute contains an XPath expression to select the data from the XML file.

**Example:**

`<#Content Select="Customer/Name" #>`

#### Tables

To generate a table, you use the `Table` element. The `Select` attribute specifies the collection of data to iterate over. The table in the template must have a prototype row, which will be repeated for each item in the data.

**Example:**

`<#Table Select="Customers/Customer" #>`

#### Conditional Content

You can conditionally include content using the `Conditional` element. The `Select` attribute specifies the data to test, and the `Match` or `NotMatch` attribute specifies the value to compare against.

**Example:**

`<#Conditional Select="Customer/Country" Match="USA" #>
... content to include if the customer is from the USA ...
<#EndConditional #>`

#### Repeating Content

To repeat a section of the document, you can use the `Repeat` element. The `Select` attribute specifies the collection of data to iterate over.

**Example:**

`<#Repeat Select="Customers/Customer" #>
... content to repeat for each customer ...
<#EndRepeat #>`

### Getting Started

To use the `DocumentAssembler`, you will need to:

1. Add a reference to the `OpenXmlPowerTools` library in your project.
2. Create a Word template with the appropriate placeholders.
3. Create an XML data file.
4. Call the `DocumentAssembler.AssembleDocument` method to generate your document.

For more detailed examples and documentation, please refer to the `DocumentAssembler`, `DocumentAssembler01`, `DocumentAssembler02`, and `DocumentAssembler03` projects in the `OpenXmlPowerToolsExamples` directory.
Loading
Loading