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
3 changes: 3 additions & 0 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6641,6 +6641,9 @@
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-retrieve-the-name-of-the-chart-in-an-Excel-worksheet">How to retrieve the name of the chart in an Excel worksheet?</a>
</li>
<li>
<a href="/document-processing/excel/excel-library/net/faqs/how-to-set-chart-title-properites-like-type-of-font, color, bold, size">How to set chart title properties like type of font, color, bold, size using XLsIO?</a>
</li>
</ul>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
title: Setting Chart properties using Syncfusion XLsIO | Syncfusion
description: This page tells how to set chart title properties like type of font, color, bold, size.
platform: document-processing
control: XlsIO
documentation: UG
---

# How to set chart title properties like type of font, color, bold, size using XLsIO?

This following code samples demonstrate how to set chart title properties like type of font, color, bold, size using C# (Cross-platform and Windows-specific) and VB.NET.

{% tabs %}
{% highlight c# tabtitle="C# [Cross-platform]" %}
using (ExcelEngine excelEngine = new ExcelEngine())
{
#region Workbook Initialization
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
IWorksheet worksheet = workbook.Worksheets[0];
#endregion

//Create a Chart
IChartShape chart = workbook.Worksheets[0].Charts.Add();

chart.DataRange = worksheet.Range["A3:C15"];
chart.ChartType = ExcelChartType.Column_Clustered;
chart.IsSeriesInRows = false;

//Formatting the chart
chart.ChartTitle = "Crescent City, CA";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartTitleArea.Bold = true;
chart.ChartTitleArea.Color = ExcelKnownColors.Red;

//Embedded Chart Position
chart.TopRow = 2;
chart.BottomRow = 30;
chart.LeftColumn = 5;
chart.RightColumn = 18;

#region Save
//Saving the workbook
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
#endregion
}
{% endhighlight %}

{% highlight c# tabtitle="C# [Windows-specific]" %}
using (ExcelEngine excelEngine = new ExcelEngine())
{
#region Workbook Initialization
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
#endregion

//Create a Chart
IChartShape chart = workbook.Worksheets[0].Charts.Add();

chart.DataRange = worksheet.Range["A3:C15"];
chart.ChartType = ExcelChartType.Column_Clustered;
chart.IsSeriesInRows = false;

//Formatting the chart
chart.ChartTitle = "Crescent City, CA";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartTitleArea.Bold = true;
chart.ChartTitleArea.Color = ExcelKnownColors.Red;

//Embedded Chart Position
chart.TopRow = 2;
chart.BottomRow = 30;
chart.LeftColumn = 5;
chart.RightColumn = 18;

#region Save
//Saving the workbook
workbook.SaveAs("Output.xlsx");
#endregion
}
{% endhighlight %}

{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
Using excelEngine As New ExcelEngine()
Dim application As IApplication = excelEngine.Excel
application.DefaultVersion = ExcelVersion.Xlsx
Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx")
Dim worksheet As IWorksheet = workbook.Worksheets(0)

'Create a Chart
Dim chart As IChartShape = workbook.Worksheets(0).Charts.Add()

chart.DataRange = worksheet.Range("A3:C15")
chart.ChartType = ExcelChartType.Column_Clustered
chart.IsSeriesInRows = False

'Formatting the chart
chart.ChartTitle = "Crescent City, CA"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartTitleArea.Bold = True
chart.ChartTitleArea.Color = ExcelKnownColors.Red

'Embedded Chart Position
chart.TopRow = 2
chart.BottomRow = 30
chart.LeftColumn = 5
chart.RightColumn = 18

'Saving the workbook
workbook.SaveAs("Output.xlsx")
End Using
{% endhighlight %}
{% endtabs %}

A complete working example in C# is present on <a href="https://github.com/SyncfusionExamples/XlsIO-Examples/tree/1006546-ChartProperties/FAQ/Chart/.NET/ChartProperties">this GitHub page</a>.