Skip to content

Commit 6417813

Browse files
authored
Merge pull request #2084 from syncfusion-content/1000731-ChartNameUG
UG documentation 1000731: FAQ for how to retrieve the name of the chart in an Excel worksheet
2 parents 87be45a + da30213 commit 6417813

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Document-Processing-toc.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6195,6 +6195,9 @@
61956195
<li>
61966196
<a href="/document-processing/excel/excel-library/net/faqs/does-xlsio-support-changing-the-colors-of-built-in-icon-sets">Does XlsIO support changing the colors of built-in icon sets?</a>
61976197
</li>
6198+
<li>
6199+
<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>
6200+
</li>
61986201
</ul>
61996202
</li>
62006203
</ul>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Retrieve the name of the chart in an Excel worksheet | Syncfusion
3+
description: Code example to retrieve the name of the chart in an Excel worksheet using Syncfusion .NET Excel library (XlsIO).
4+
platform: document-processing
5+
control: XlsIO
6+
documentation: UG
7+
---
8+
9+
# How to retrieve the name of the chart in an Excel worksheet?
10+
11+
The following code examples demonstrate retrieving the name of the chart in an Excel worksheet using C# (Cross-platform and Windows-specific) and VB.NET.
12+
13+
{% tabs %}
14+
{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Chart/.NET/ChartNameInWorksheet/ChartNameInWorksheet/Program.cs,180" %}
15+
using (ExcelEngine excelEngine = new ExcelEngine())
16+
{
17+
IApplication application = excelEngine.Excel;
18+
application.DefaultVersion = ExcelVersion.Xlsx;
19+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx"));
20+
IWorksheet worksheet = workbook.Worksheets[0];
21+
22+
//Get the chart name
23+
string chartName = worksheet.Charts[0].Name;
24+
//Display the chart name
25+
Console.WriteLine("The name of the chart is: " + chartName);
26+
27+
//Saving the workbook
28+
workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx"));
29+
}
30+
{% endhighlight %}
31+
32+
{% highlight c# tabtitle="C# [Windows-specific]" %}
33+
using (ExcelEngine excelEngine = new ExcelEngine())
34+
{
35+
IApplication application = excelEngine.Excel;
36+
application.DefaultVersion = ExcelVersion.Xlsx;
37+
IWorkbook workbook = application.Workbooks.Open("Input.xlsx");
38+
IWorksheet worksheet = workbook.Worksheets[0];
39+
40+
//Get the chart name
41+
string chartName = worksheet.Charts[0].Name;
42+
//Display the chart name
43+
Console.WriteLine("The name of the chart is: " + chartName);
44+
45+
//Saving the workbook
46+
workbook.SaveAs("Output.xlsx");
47+
}
48+
{% endhighlight %}
49+
50+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
51+
Using excelEngine As New ExcelEngine()
52+
' Access the IApplication instance
53+
Dim application As IApplication = excelEngine.Excel
54+
55+
' Set the default version
56+
application.DefaultVersion = ExcelVersion.Xlsx
57+
58+
' Open the input workbook
59+
Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx")
60+
61+
' Get the first worksheet
62+
Dim worksheet As IWorksheet = workbook.Worksheets(0)
63+
64+
' Get the chart name
65+
Dim chartName As String = worksheet.Charts(0).Name
66+
67+
' Display the chart name
68+
Console.WriteLine("The name of the chart is: " & chartName)
69+
70+
' Save the workbook to output
71+
workbook.SaveAs("Output.xlsx")
72+
End Using
73+
{% endhighlight %}
74+
{% endtabs %}
75+
76+
A complete working example in C# is present on <a href="https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/FAQ/Chart/.NET/ChartNameInWorksheet">this GitHub page</a>.

0 commit comments

Comments
 (0)