Skip to content

Commit

Permalink
Use Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurmitha4004 committed Oct 16, 2024
1 parent 6f6c0c3 commit 0b83fae
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Use Cases/Gauge Chart/.NET/Gauge Chart/Gauge Chart.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34310.174
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gauge Chart", "Gauge Chart\Gauge Chart.csproj", "{BD0D7A75-D255-4E74-A4F6-43B01D304A95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD0D7A75-D255-4E74-A4F6-43B01D304A95}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A3C33441-1A09-4DE1-ABCE-5F44914B94B9}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Gauge_Chart</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Empty file.
59 changes: 59 additions & 0 deletions Use Cases/Gauge Chart/.NET/Gauge Chart/Gauge Chart/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Syncfusion.XlsIO;
using System;

namespace GaugeChart
{
class Program
{
public static void Main(string[] args)
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];

//Adding values in worksheet
sheet.Range["A1"].Value = "Value";
sheet.Range["A2"].Value = "30";
sheet.Range["A3"].Value = "60";
sheet.Range["A4"].Value = "90";
sheet.Range["A5"].Value = "180";
sheet.Range["C2"].Value = "value";
sheet.Range["C3"].Value = "pointer";
sheet.Range["C4"].Value = "End";
sheet.Range["D2"].Value = "10";
sheet.Range["D3"].Value = "1";
sheet.Range["D4"].Value = "189";

//Adding doughnut chart in worksheet
IChartShape chart = sheet.Charts.Add();
chart.ChartType = ExcelChartType.Doughnut;
chart.DataRange = sheet.Range["A1:A5"];
chart.IsSeriesInRows = false;

//Formatting value series
chart.Series["Value"].SerieFormat.CommonSerieOptions.DoughnutHoleSize = 60;
chart.Series["Value"].SerieFormat.CommonSerieOptions.FirstSliceAngle = 270;
chart.Series["Value"].DataPoints[3].DataFormat.Fill.Visible = false;

//Adding pointer series as Pie chart
chart.Series.Add("Pointer");
chart.Series["Pointer"].SerieType = ExcelChartType.Pie;
chart.Series["Pointer"].Values = sheet.Range["D2:D4"];
chart.Series["Pointer"].UsePrimaryAxis = false;

//Formatting pointer series
chart.Series["Pointer"].SerieFormat.CommonSerieOptions.FirstSliceAngle = 270;
chart.Series["Pointer"].DataPoints[0].DataFormat.Fill.Visible = false;
chart.Series["Pointer"].DataPoints[1].DataFormat.Fill.ForeColorIndex = ExcelKnownColors.Black;
chart.Series["Pointer"].DataPoints[2].DataFormat.Fill.Visible = false;

//Saving the workbook as stream
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
workbook.SaveAs(outputStream);
}
}
}
}

0 comments on commit 0b83fae

Please sign in to comment.