Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36915.13 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accept-All-Changes-Word-document", "Accept-All-Changes-Word-document\Accept-All-Changes-Word-document.csproj", "{091C5157-E742-7A50-D648-F46E1D32F5B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{091C5157-E742-7A50-D648-F46E1D32F5B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{091C5157-E742-7A50-D648-F46E1D32F5B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{091C5157-E742-7A50-D648-F46E1D32F5B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{091C5157-E742-7A50-D648-F46E1D32F5B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB90BBCF-EBA0-4566-9135-989B947554B8}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Accept_All_Changes_Word_document</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="Data\Input.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System.Diagnostics;

namespace Accept_All_Changes_Word_document
{
class Program
{
static void Main(string[] args)
{
//Load the document.
using (FileStream inputFileStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read))
{
//Load the word document.
using (WordDocument wordDocument = new WordDocument(inputFileStream, FormatType.Docx))
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
//Accepts all the tracked changes revisions in the Word document
if (wordDocument.HasChanges)
wordDocument.Revisions.AcceptAll();
stopwatch.Stop();
Console.WriteLine($"Time taken for accept all changes in word Document: " + stopwatch.Elapsed.TotalSeconds);
//Create file stream
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the Word document to file stream
wordDocument.Save(outputFileStream, FormatType.Docx);
}
}
}
}
}
}

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Find-and-Replace/Find-and-Replace.csproj" />
</Solution>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Find_and_Replace</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System.Diagnostics;

namespace Find_and_replace_in_a_worddocument
{
class Program
{
static void Main(string[] args)
{
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
//Open the template Word document.
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic))
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
//Find all occurrences of a misspelled word and replaces with properly spelled word
int replacedCount = document.Replace("document", "DocIO", false, false);
stopwatch.Stop();
Console.WriteLine($"Count of replaced words in the word Document: " + replacedCount);
Console.WriteLine($"Time taken for Replace (string):" + stopwatch.Elapsed.TotalSeconds);
//Create file stream
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the Word document to file stream
document.Save(outputFileStream, FormatType.Docx);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36915.13 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mail-Merge-Word-document", "Mail-Merge-Word-document\Mail-Merge-Word-document.csproj", "{6CC5936C-F8A1-5A2B-88D6-BFE228F5D889}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6CC5936C-F8A1-5A2B-88D6-BFE228F5D889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CC5936C-F8A1-5A2B-88D6-BFE228F5D889}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CC5936C-F8A1-5A2B-88D6-BFE228F5D889}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CC5936C-F8A1-5A2B-88D6-BFE228F5D889}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {81910D4A-53B0-4C43-82F1-FE55DF40458A}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Mail_Merge_Word_document</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>
<ItemGroup>
<None Update="Data\Template.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Loading