diff --git a/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart.sln b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart.sln new file mode 100644 index 000000000..37f7ddd99 --- /dev/null +++ b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-and-edit-shape-chart", "Find-and-edit-shape-chart\Find-and-edit-shape-chart.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} + EndGlobalSection +EndGlobal diff --git a/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Data/Template.docx b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Data/Template.docx new file mode 100644 index 000000000..69eecc4a0 Binary files /dev/null and b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Data/Template.docx differ diff --git a/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Find-and-edit-shape-chart.csproj b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Find-and-edit-shape-chart.csproj new file mode 100644 index 000000000..84c686c43 --- /dev/null +++ b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Find-and-edit-shape-chart.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + Find_and_edit_shape_chart + + + + + + + + + Always + + + Always + + + + diff --git a/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Output/.gitkeep b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Program.cs b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Program.cs new file mode 100644 index 000000000..6dc32ddd5 --- /dev/null +++ b/Find-item-in-word-document/Find-and-edit-shape-chart/.NET/Find-and-edit-shape-chart/Program.cs @@ -0,0 +1,41 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using System.IO; + +namespace Find_and_edit_shape_chart +{ + class Program + { + static void Main(string[] args) + { + 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)) + { + //Find shape by name. + Shape shape = document.FindItemByProperty(EntityType.AutoShape, "Name", "Adventure Shape") as Shape; + //Resize the shape. + if (shape != null) + { + shape.Height = 75; + shape.Width = 200; + } + //Find chart by name. + WChart chart = document.FindItemByProperty(EntityType.Chart, "Name", "Adventure Chart") as WChart; + //Set the chart name. + if (chart != null) + chart.ChartTitle = "Column chart"; + + //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); + } + } + } + } + } +} +