Skip to content

Commit 0b83fae

Browse files
committed
Use Cases
1 parent 6f6c0c3 commit 0b83fae

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-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 17
4+
VisualStudioVersion = 17.9.34310.174
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gauge Chart", "Gauge Chart\Gauge Chart.csproj", "{BD0D7A75-D255-4E74-A4F6-43B01D304A95}"
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+
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.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 = {A3C33441-1A09-4DE1-ABCE-5F44914B94B9}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Gauge_Chart</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\*">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\*">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
</Project>

Use Cases/Gauge Chart/.NET/Gauge Chart/Gauge Chart/Output/.gitkeep

Whitespace-only changes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Syncfusion.XlsIO;
2+
using System;
3+
4+
namespace GaugeChart
5+
{
6+
class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
using (ExcelEngine excelEngine = new ExcelEngine())
11+
{
12+
IApplication application = excelEngine.Excel;
13+
application.DefaultVersion = ExcelVersion.Xlsx;
14+
IWorkbook workbook = application.Workbooks.Create(1);
15+
IWorksheet sheet = workbook.Worksheets[0];
16+
17+
//Adding values in worksheet
18+
sheet.Range["A1"].Value = "Value";
19+
sheet.Range["A2"].Value = "30";
20+
sheet.Range["A3"].Value = "60";
21+
sheet.Range["A4"].Value = "90";
22+
sheet.Range["A5"].Value = "180";
23+
sheet.Range["C2"].Value = "value";
24+
sheet.Range["C3"].Value = "pointer";
25+
sheet.Range["C4"].Value = "End";
26+
sheet.Range["D2"].Value = "10";
27+
sheet.Range["D3"].Value = "1";
28+
sheet.Range["D4"].Value = "189";
29+
30+
//Adding doughnut chart in worksheet
31+
IChartShape chart = sheet.Charts.Add();
32+
chart.ChartType = ExcelChartType.Doughnut;
33+
chart.DataRange = sheet.Range["A1:A5"];
34+
chart.IsSeriesInRows = false;
35+
36+
//Formatting value series
37+
chart.Series["Value"].SerieFormat.CommonSerieOptions.DoughnutHoleSize = 60;
38+
chart.Series["Value"].SerieFormat.CommonSerieOptions.FirstSliceAngle = 270;
39+
chart.Series["Value"].DataPoints[3].DataFormat.Fill.Visible = false;
40+
41+
//Adding pointer series as Pie chart
42+
chart.Series.Add("Pointer");
43+
chart.Series["Pointer"].SerieType = ExcelChartType.Pie;
44+
chart.Series["Pointer"].Values = sheet.Range["D2:D4"];
45+
chart.Series["Pointer"].UsePrimaryAxis = false;
46+
47+
//Formatting pointer series
48+
chart.Series["Pointer"].SerieFormat.CommonSerieOptions.FirstSliceAngle = 270;
49+
chart.Series["Pointer"].DataPoints[0].DataFormat.Fill.Visible = false;
50+
chart.Series["Pointer"].DataPoints[1].DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Black;
51+
chart.Series["Pointer"].DataPoints[2].DataFormat.Fill.Visible = false;
52+
53+
//Saving the workbook as stream
54+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
55+
workbook.SaveAs(outputStream);
56+
}
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)