diff --git a/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title.sln b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title.sln new file mode 100644 index 000000000..1faf32420 --- /dev/null +++ b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-and-remove-table-by-title", "Find-and-remove-table-by-title\Find-and-remove-table-by-title.csproj", "{EA22BFD7-89F9-4F72-BECC-743931FBDFA6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EA22BFD7-89F9-4F72-BECC-743931FBDFA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA22BFD7-89F9-4F72-BECC-743931FBDFA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA22BFD7-89F9-4F72-BECC-743931FBDFA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA22BFD7-89F9-4F72-BECC-743931FBDFA6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ADDC6FEE-8718-4B00-B091-6C4DC0CBF62A} + EndGlobalSection +EndGlobal diff --git a/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Data/Template.docx b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Data/Template.docx new file mode 100644 index 000000000..33fe79d5c Binary files /dev/null and b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Data/Template.docx differ diff --git a/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Find-and-remove-table-by-title.csproj b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Find-and-remove-table-by-title.csproj new file mode 100644 index 000000000..51b5dd90a --- /dev/null +++ b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Find-and-remove-table-by-title.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + Find_and_remove_table_by_title + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Output/.gitkeep b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Program.cs b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Program.cs new file mode 100644 index 000000000..4307ce325 --- /dev/null +++ b/Tables/Find-and-remove-table-by-title/.NET/Find-and-remove-table-by-title/Program.cs @@ -0,0 +1,31 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; + +namespace Find_and_remove_table_by_title +{ + internal class Program + { + static void Main(string[] args) + { + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.ReadWrite)) + { + using (WordDocument document = new WordDocument(fileStream, FormatType.Automatic)) + { + // Find the table with title. + WTable table = document.FindItemByProperty(EntityType.Table, "Title", "Product Overview") as WTable; + + if (table != null) + { + // Remove table from document + table.OwnerTextBody.ChildEntities.Remove(table); + } + + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + document.Save(outputStream, FormatType.Docx); + } + } + } + } + } +}