diff --git a/Find-and-Replace/Find-match-case/.NET/Find-match-case.sln b/Find-and-Replace/Find-match-case/.NET/Find-match-case.sln new file mode 100644 index 000000000..c359c62f0 --- /dev/null +++ b/Find-and-Replace/Find-match-case/.NET/Find-match-case.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35417.141 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-match-case", "Find-match-case\Find-match-case.csproj", "{51F6D2BA-42F2-4921-A14E-E23C3462B09A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {51F6D2BA-42F2-4921-A14E-E23C3462B09A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51F6D2BA-42F2-4921-A14E-E23C3462B09A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51F6D2BA-42F2-4921-A14E-E23C3462B09A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51F6D2BA-42F2-4921-A14E-E23C3462B09A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Find-and-Replace/Find-match-case/.NET/Find-match-case/Data/Template.docx b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Data/Template.docx new file mode 100644 index 000000000..9a63bd9df Binary files /dev/null and b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Data/Template.docx differ diff --git a/Find-and-Replace/Find-match-case/.NET/Find-match-case/Find-match-case.csproj b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Find-match-case.csproj new file mode 100644 index 000000000..0c6c5cabf --- /dev/null +++ b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Find-match-case.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + Find_match_case + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Find-and-Replace/Find-match-case/.NET/Find-match-case/Output/.gitkeep b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Find-and-Replace/Find-match-case/.NET/Find-match-case/Program.cs b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Program.cs new file mode 100644 index 000000000..e932e0fa9 --- /dev/null +++ b/Find-and-Replace/Find-match-case/.NET/Find-match-case/Program.cs @@ -0,0 +1,25 @@ +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIO; +using Syncfusion.Drawing; + +using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) +{ + //Opens an existing Word document. + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic)) + { + // Finds the first occurrence of a particular text that matches the exact case in the document. + TextSelection textSelection = document.Find("adventure", true, false); + //Gets the found text as single text range. + WTextRange textRange = textSelection.GetAsOneRange(); + //Modifies the text. + textRange.Text = "Replaced text"; + //Sets highlight color. + textRange.CharacterFormat.HighlightColor = Color.Yellow; + //Creates file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Saves the Word document to file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } +} diff --git a/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document.sln b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document.sln new file mode 100644 index 000000000..7b83eb063 --- /dev/null +++ b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35417.141 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-text-in-Word-document", "Find-text-in-Word-document\Find-text-in-Word-document.csproj", "{83A04CC7-7718-4BE2-979B-167DBE12DF36}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {83A04CC7-7718-4BE2-979B-167DBE12DF36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83A04CC7-7718-4BE2-979B-167DBE12DF36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83A04CC7-7718-4BE2-979B-167DBE12DF36}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83A04CC7-7718-4BE2-979B-167DBE12DF36}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Data/Template.docx b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Data/Template.docx new file mode 100644 index 000000000..fbfefc203 Binary files /dev/null and b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Data/Template.docx differ diff --git a/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Find-text-in-Word-document.csproj b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Find-text-in-Word-document.csproj new file mode 100644 index 000000000..82021cbb5 --- /dev/null +++ b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Find-text-in-Word-document.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + Find_text_in_Word_document + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Output/.gitkeep b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Program.cs b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Program.cs new file mode 100644 index 000000000..250c66bf3 --- /dev/null +++ b/Find-and-Replace/Find-text-in-Word-document/.NET/Find-text-in-Word-document/Program.cs @@ -0,0 +1,25 @@ +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIO; +using Syncfusion.Drawing; + +using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) +{ + //Opens an existing Word document. + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic)) + { + // Finds the first occurrence of a particular text that matches whole words in the document. + TextSelection textSelection = document.Find("Adventure Works Cycles", false, true); + //Gets the found text as single text range. + WTextRange textRange = textSelection.GetAsOneRange(); + //Modifies the text. + textRange.Text = "Replaced text"; + //Sets highlight color. + textRange.CharacterFormat.HighlightColor = Color.Yellow; + //Creates file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Saves the Word document to file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } +} diff --git a/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only.sln b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only.sln new file mode 100644 index 000000000..54cde9b12 --- /dev/null +++ b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35417.141 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-whole-words-only", "Find-whole-words-only\Find-whole-words-only.csproj", "{8D737D63-1B30-4FBC-910F-D264B797BA7A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8D737D63-1B30-4FBC-910F-D264B797BA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D737D63-1B30-4FBC-910F-D264B797BA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D737D63-1B30-4FBC-910F-D264B797BA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D737D63-1B30-4FBC-910F-D264B797BA7A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Data/Template.docx b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Data/Template.docx new file mode 100644 index 000000000..fbfefc203 Binary files /dev/null and b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Data/Template.docx differ diff --git a/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Find-whole-words-only.csproj b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Find-whole-words-only.csproj new file mode 100644 index 000000000..2e05a1285 --- /dev/null +++ b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Find-whole-words-only.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + Find_whole_words_only + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Output/.gitkeep b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Program.cs b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Program.cs new file mode 100644 index 000000000..908fee87b --- /dev/null +++ b/Find-and-Replace/Find-whole-words-only/.NET/Find-whole-words-only/Program.cs @@ -0,0 +1,25 @@ +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIO; +using Syncfusion.Drawing; + +using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) +{ + //Opens an existing Word document. + using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic)) + { + // Finds the first occurrence of a particular text that matches whole words in the document. + TextSelection textSelection = document.Find("AdventureWorks", false, true); + //Gets the found text as single text range. + WTextRange textRange = textSelection.GetAsOneRange(); + //Modifies the text. + textRange.Text = "Replaced text"; + //Sets highlight color. + textRange.CharacterFormat.HighlightColor = Color.Yellow; + //Creates file stream. + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Saves the Word document to file stream. + document.Save(outputFileStream, FormatType.Docx); + } + } +}