Skip to content

Commit ed05c8a

Browse files
ES-891633-Add-data-table
1 parent 3d293e6 commit ed05c8a

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31911.196
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-data-table", "Add-data-table\Add-data-table.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Add_data_table</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Output\.gitkeep">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.OfficeChart;
4+
using System.IO;
5+
6+
namespace AddDataTable
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
// Create a new Word document.
13+
WordDocument document = new WordDocument();
14+
15+
// Add a section to the document.
16+
IWSection section = document.AddSection();
17+
18+
// Add a paragraph to the section.
19+
IWParagraph paragraph = section.AddParagraph();
20+
21+
// Create and append the chart to the paragraph.
22+
WChart chart = paragraph.AppendChart(446, 270);
23+
24+
// Set chart type.
25+
chart.ChartType = OfficeChartType.Column_Clustered;
26+
27+
// Set chart data.
28+
chart.ChartData.SetValue(2, 1, "Apples");
29+
chart.ChartData.SetValue(3, 1, "Grapes");
30+
chart.ChartData.SetValue(4, 1, "Banana");
31+
32+
chart.ChartData.SetValue(1, 2, "Joey");
33+
chart.ChartData.SetValue(2, 2, 5);
34+
chart.ChartData.SetValue(3, 2, 4);
35+
chart.ChartData.SetValue(4, 2, 4);
36+
37+
// Define the data range for the chart.
38+
chart.DataRange = chart.ChartData[1, 1, 4, 2];
39+
40+
// Add data table to the chart.
41+
chart.HasDataTable = true;
42+
IOfficeChartDataTable officeChartDataTable = chart.DataTable;
43+
44+
// Customize the data table appearance.
45+
officeChartDataTable.ShowSeriesKeys = true;
46+
officeChartDataTable.HasBorders = true;
47+
officeChartDataTable.HasHorzBorder = true;
48+
officeChartDataTable.HasVertBorder = true;
49+
50+
// Create a file stream to save the document.
51+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
52+
{
53+
// Save the Word document to the file stream.
54+
document.Save(outputFileStream, FormatType.Docx);
55+
}
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)