DocumentFormat.OpenXml.VariableReplacer 0.1.0

using (WordprocessingDocument document = WordprocessingDocument.Open(filePath, true))
{
MainDocumentPart mainPart = document.MainDocumentPart;
Dictionary<string, string> replacers = new Dictionary<string, string>(32);
_openXmlVariableReplacer.ReplaceVariables(mainPart.Document, replacers);
}

Install-Package DocumentFormat.OpenXml.VariableReplacer -Version 0.1.0
dotnet add package DocumentFormat.OpenXml.VariableReplacer --version 0.1.0
<PackageReference Include="DocumentFormat.OpenXml.VariableReplacer" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DocumentFormat.OpenXml.VariableReplacer --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DocumentFormat.OpenXml.VariableReplacer, 0.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install DocumentFormat.OpenXml.VariableReplacer as a Cake Addin
#addin nuget:?package=DocumentFormat.OpenXml.VariableReplacer&version=0.1.0

// Install DocumentFormat.OpenXml.VariableReplacer as a Cake Tool
#tool nuget:?package=DocumentFormat.OpenXml.VariableReplacer&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

open-xml-variable-replacer

Simple and lightweight replacer for varibles in OpenXml (DOCX MS Word).

Installation (via Nuget)

Install-Package DocumentFormat.OpenXml.VariableReplacer -Version 0.1.0

Usage

  1. Register or initialize:
IVariableReplacer _openXmlVariableReplacer = new VariableReplacer();

or some DI like this:

serviceCollection.AddTransient<IVariableReplacer, VariableReplacer>();
  1. Use:
using (WordprocessingDocument document = WordprocessingDocument.Open(filePath, true))
{
    MainDocumentPart mainPart = document.MainDocumentPart;
    Dictionary<string, string> replacers = new Dictionary<string, string> { 
      {"MyVariable", "MyNewText"},
      {"MyVariable2", "MyNewText2"},
      {"MyVariable3", "MyNewText3"},
      // ...
    };
    _openXmlVariableReplacer.ReplaceVariables(mainPart.Document, replacers);
}

open-xml-variable-replacer

Simple and lightweight replacer for varibles in OpenXml (DOCX MS Word).

Installation (via Nuget)

Install-Package DocumentFormat.OpenXml.VariableReplacer -Version 0.1.0

Usage

  1. Register or initialize:
IVariableReplacer _openXmlVariableReplacer = new VariableReplacer();

or some DI like this:

serviceCollection.AddTransient<IVariableReplacer, VariableReplacer>();
  1. Use:
using (WordprocessingDocument document = WordprocessingDocument.Open(filePath, true))
{
    MainDocumentPart mainPart = document.MainDocumentPart;
    Dictionary<string, string> replacers = new Dictionary<string, string> { 
      {"MyVariable", "MyNewText"},
      {"MyVariable2", "MyNewText2"},
      {"MyVariable3", "MyNewText3"},
      // ...
    };
    _openXmlVariableReplacer.ReplaceVariables(mainPart.Document, replacers);
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.0 2,173 12/4/2017