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.

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);
}

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.0 1,548 12/4/2017