Wordize for .NET ist eine effiziente Lösung für die Textersetzung in Word-Dokumenten. Die Replacer-Klasse ermöglicht es C#-Entwicklern, Textfragmente in Word-Dateien programmatisch zu ersetzen, sowohl mit einfachen Strings als auch mit regulären Ausdrücken.
Hauptfunktionen:Testen Sie die Möglichkeiten der programmatischen Word-Textersetzung in der interaktiven Online-Demo, die auf dieser Seite präsentiert wird. Laden Sie dazu Ihr Word-Dokument hoch, geben Sie den Suchtext und den Ersetzungstext an, führen Sie die Operation aus und laden Sie die aktualisierte Datei zur Überprüfung herunter. Der bereitgestellte C#-Codeausschnitt ist vollständig bereit für die Verwendung in Ihrem .NET-Projekt.
using Wordize.Replacing;
Replacer.Replace("Input.docx", "Output.docx", "Text oder Regex", "Text oder Regex");
using Wordize.Replacing;
Replacer.Replace("Input.docx", "Output.docx", "Text oder Regex", "Text oder Regex");
using Wordize.Replacing;
using Wordize.Saving;
var imageStreams = Replacer.ReplaceToImages("Input.docx",
new ImageSaveOptions(SaveFormat.Docx), "Text oder Regex", "Text oder Regex");
foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i)))
{
using var _ = stream;
stream.Position = 0;
using var file = File.Create($"Output_{page + 1}.docx");
stream.CopyTo(file);
}
using Wordize.Replacing;
FindReplaceOptions options = new FindReplaceOptions() { UseSubstitutions = true };
Replacer.Replace("Input.docx", "Output.docx", new Regex(@"Text oder Regex"), "Text oder Regex", options);
using Wordize.Replacing;
FindReplaceOptions options = new FindReplaceOptions() { UseSubstitutions = true };
Replacer.Replace("Input.docx", "Output.docx", new Regex(@"Text oder Regex"), "Text oder Regex", options);
using Wordize.Replacing;
using Wordize.Saving;
FindReplaceOptions options = new FindReplaceOptions() { UseSubstitutions = true };
var imageStreams = Replacer.ReplaceToImages("Input.docx",
new ImageSaveOptions(SaveFormat.Docx), new Regex(@"Text oder Regex"), "Text oder Regex", options);
foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i)))
{
using var _ = stream;
stream.Position = 0;
using var file = File.Create($"Output_{page + 1}.docx");
stream.CopyTo(file);
}