Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Use Cases/SalesTrendWithSparklines/SalesTrendWithSparklines.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.14.36109.1 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SalesTrendWithSparklines", "SalesTrendWithSparklines\SalesTrendWithSparklines.csproj", "{65DA17F0-EE05-41AC-B641-277B8ADDC9A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{65DA17F0-EE05-41AC-B641-277B8ADDC9A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65DA17F0-EE05-41AC-B641-277B8ADDC9A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65DA17F0-EE05-41AC-B641-277B8ADDC9A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65DA17F0-EE05-41AC-B641-277B8ADDC9A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {028FC0D5-08B9-4204-8E36-62B25FAD4F06}
EndGlobalSection
EndGlobal
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

using Syncfusion.XlsIO;
using Syncfusion.Drawing;
using System.IO;

class SalesTrendWithSparklines
{
static void Main()
{
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;

// Load the Excel file with sales data
FileStream inputStream = new FileStream("../../../Data/Sales Data.xlsx", FileMode.Open, FileAccess.Read);

IWorkbook workbook = application.Workbooks.Open(inputStream);
IWorksheet sheet = workbook.Worksheets[0];

sheet["G1"].Text = "Sales Trend";
sheet["G1"].CellStyle.Font.Bold = true;

// Create a Sparkline Group
ISparklineGroup sparklineGroup = sheet.SparklineGroups.Add();

// Add a Line Sparkline to the group
ISparklines sparklines = sparklineGroup.Add();

// Define the data range and reference range for the sparkline
IRange dataRange = sheet.Range["B2:F26"];
IRange referenceRange = sheet.Range["G2:G26"];
sparklines.Add(dataRange, referenceRange);

// Set the sparkline type to Line
sparklineGroup.SparklineType = SparklineType.Line;

// Customizing Line Sparkline
sparklineGroup.LineWeight = 1;
sparklineGroup.ShowMarkers = true;

//Set sparkline line color
sparklineGroup.SparklineColor = Color.Orange;

// Set the high and low point colors
sparklineGroup.HighPointColor = Color.Red;
sparklineGroup.LowPointColor = Color.Green;

//Customizing markers
sparklineGroup.MarkersColor = Color.Blue;

// Save the Excel file
using (FileStream stream = new FileStream("SalesDataTrend.xlsx", FileMode.Create, FileAccess.Write))
{
workbook.SaveAs(stream);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>