Skip to content

Commit bcda1f0

Browse files
authored
Merge pull request #307 from SyncfusionExamples/1006546-ChartProperties
UG documentation 1006546: FAQ for how to set chart title properites like type of font, color, bold, size using XlsIO?
2 parents a9a25aa + 34b84ac commit bcda1f0

5 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="ChartProperties/ChartProperties.csproj" />
3+
</Solution>
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+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Data\*">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Output\*">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>
Binary file not shown.

FAQ/Chart/.NET/ChartProperties/ChartProperties/Output/.gitkeep

Whitespace-only changes.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using Syncfusion.XlsIO;
3+
4+
namespace ChartProperties
5+
{
6+
class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
using (ExcelEngine excelEngine = new ExcelEngine())
11+
{
12+
#region Workbook Initialization
13+
IApplication application = excelEngine.Excel;
14+
application.DefaultVersion = ExcelVersion.Xlsx;
15+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
16+
IWorksheet worksheet = workbook.Worksheets[0];
17+
#endregion
18+
19+
//Create a Chart
20+
IChartShape chart = workbook.Worksheets[0].Charts.Add();
21+
22+
chart.DataRange = worksheet.Range["A3:C15"];
23+
chart.ChartType = ExcelChartType.Column_Clustered;
24+
chart.IsSeriesInRows = false;
25+
26+
//Formatting the chart
27+
chart.ChartTitle = "Crescent City, CA";
28+
chart.ChartTitleArea.FontName = "Calibri";
29+
chart.ChartTitleArea.Size = 14;
30+
chart.ChartTitleArea.Bold = true;
31+
chart.ChartTitleArea.Color = ExcelKnownColors.Red;
32+
33+
//Embedded Chart Position
34+
chart.TopRow = 2;
35+
chart.BottomRow = 30;
36+
chart.LeftColumn = 5;
37+
chart.RightColumn = 18;
38+
39+
#region Save
40+
//Saving the workbook
41+
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
42+
#endregion
43+
}
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)