Skip to content

Commit 8269c3e

Browse files
Merge pull request #2092 from Syncfusion-Content/hotfix/hotfix-v25.1.35
DOCINFRA-2341_merged_using_automation
2 parents b2ac690 + eb259dc commit 8269c3e

File tree

5 files changed

+347
-1
lines changed

5 files changed

+347
-1
lines changed

File-Formats-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,7 @@
16891689
<li><a href="/file-formats/xlsio/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document">How to set Logarithmic axis for chart in Excel document?</a></li>
16901690
<li><a href="/file-formats/xlsio/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows">How to resolve performance issue when deleting a large number of rows?</a></li>
16911691
<li><a href="/file-formats/xlsio/faqs/how-to-hide-columns-using-column-name">How to hide columns using column name?</a></li>
1692+
<li><a href="/file-formats/xlsio/faqs/how-to-convert-xls-document-to-xlsx-format-document">How to convert xls document to xlsx format document?</a></li>
16921693
</ul>
16931694
</li>
16941695
</ul>

File-Formats/XlsIO/FAQ.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ The frequently asked questions in Essential XlsIO are listed below.
8383
* [How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?](faqs/how-to-fix-the-argument-out-of-range-exception-when-accessing-a-large-number-of-rows-and-columns)
8484
* [How to set Logarithmic axis for chart in Excel document?](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document)
8585
* [How to resolve performance issue when deleting a large number of rows?](faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows)
86-
* [How to hide columns using column name](faqs/how-to-hide-columns-using-column-name)
86+
* [How to hide columns using column name?](faqs/how-to-hide-columns-using-column-name)
87+
* [How to convert xls document to xlsx format document?](faqs/how-to-convert-xls-document-to-xlsx-format-document)
49.9 KB
Loading

File-Formats/XlsIO/Working-with-Charts.md

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,53 @@ serieTwo.SerieFormat.MarkerForegroundColor = Color.DarkGreen
691691
{% endhighlight %}
692692
{% endtabs %}
693693

694+
### Different Data Label Properties
695+
696+
{% tabs %}
697+
{% highlight c# tabtitle="C# [Cross-platform]" %}
698+
IChartSerie serieOne = chart.Series[0];
699+
700+
//Set data label as value.
701+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
702+
703+
//Set data label from the range of cells
704+
serieOne.DataPoints.DefaultDataPoint.DataLabels.ValueFromCellsRange = sheet["B4:B6"];
705+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValueFromCells = true;
706+
707+
//Set the position of the data label
708+
serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Inside;
709+
{% endhighlight %}
710+
711+
{% highlight c# tabtitle="C# [Windows-specific]" %}
712+
IChartSerie serieOne = chart.Series[0];
713+
714+
//Set data label as value.
715+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
716+
717+
//Set data label from the range of cells
718+
serieOne.DataPoints.DefaultDataPoint.DataLabels.ValueFromCellsRange = sheet["B4:B6"];
719+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValueFromCells = true;
720+
721+
//Set the position of the data label
722+
serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Inside;
723+
{% endhighlight %}
724+
725+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
726+
Dim serieOne As IChartSerie = chart.Series(0)
727+
728+
'Set data label as value.
729+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
730+
731+
'Set data label from the range of cells
732+
serieOne.DataPoints.DefaultDataPoint.DataLabels.ValueFromCellsRange = sheet("B4:B6")
733+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValueFromCells = True
734+
735+
'Set the position of the data label
736+
serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Inside
737+
738+
{% endhighlight %}
739+
{% endtabs %}
740+
694741
### Different Legend Properties
695742

696743
{% tabs %}
@@ -812,7 +859,14 @@ using (ExcelEngine excelEngine = new ExcelEngine())
812859
chart.SecondaryCategoryAxis.Border.LineColor = Color.Transparent;
813860
chart.SecondaryCategoryAxis.MajorTickMark = ExcelTickMark.TickMark_None;
814861
chart.SecondaryCategoryAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_None;
862+
863+
//Set data label from the range of cells
864+
serieOne.DataPoints.DefaultDataPoint.DataLabels.ValueFromCellsRange = sheet["B4:B6"];
865+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValueFromCells = true;
815866

867+
//Set the position of the data label
868+
serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Inside;
869+
816870
//Set legend properties
817871
chart.Legend.Position = ExcelLegendPosition.Bottom;
818872
chart.Legend.IsVerticalLegend = false;
@@ -905,6 +959,13 @@ using (ExcelEngine excelEngine = new ExcelEngine())
905959
chart.SecondaryCategoryAxis.Border.LineColor = Color.Transparent;
906960
chart.SecondaryCategoryAxis.MajorTickMark = ExcelTickMark.TickMark_None;
907961
chart.SecondaryCategoryAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_None;
962+
963+
//Set data label from the range of cells
964+
serieOne.DataPoints.DefaultDataPoint.DataLabels.ValueFromCellsRange = sheet["B4:B6"];
965+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValueFromCells = true;
966+
967+
//Set the position of the data label
968+
serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Inside;
908969

909970
//Set legend properties
910971
chart.Legend.Position = ExcelLegendPosition.Bottom;
@@ -997,6 +1058,13 @@ Using excelEngine As ExcelEngine = New ExcelEngine()
9971058
chart.SecondaryCategoryAxis.MajorTickMark = ExcelTickMark.TickMark_None
9981059
chart.SecondaryCategoryAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_None
9991060

1061+
'Set data label from the range of cells
1062+
serieOne.DataPoints.DefaultDataPoint.DataLabels.ValueFromCellsRange = sheet("B4:B6")
1063+
serieOne.DataPoints.DefaultDataPoint.DataLabels.IsValueFromCells = True
1064+
1065+
'Set the position of the data label
1066+
serieOne.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Inside
1067+
10001068
'Set legend properties
10011069
chart.Legend.Position = ExcelLegendPosition.Bottom
10021070
chart.Legend.IsVerticalLegend = False
@@ -2110,6 +2178,216 @@ End Using
21102178

21112179
A complete working example to fill chart area with picture in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Create%20and%20Edit%20Charts/Picture%20in%20Chart%20Area).
21122180

2181+
## Gradient Fill
2182+
2183+
A gradient fill in a chart refers to the application of a smooth transition of colors across a chart element. Instead of a solid color, a gradient fill gradually blends one color into another, creating a visually appealing effect.
2184+
2185+
The following code example explains how to apply gradient fill in the chart data series.
2186+
2187+
{% tabs %}
2188+
{% highlight c# tabtitle="C# [Cross-platform]" %}
2189+
using (ExcelEngine excelEngine = new ExcelEngine())
2190+
{
2191+
IApplication application = excelEngine.Excel;
2192+
application.DefaultVersion = ExcelVersion.Xlsx;
2193+
FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read);
2194+
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
2195+
IWorksheet sheet = workbook.Worksheets[0];
2196+
2197+
//Create a Chart
2198+
IChartShape chart = sheet.Charts.Add();
2199+
2200+
//Set Chart Type
2201+
chart.ChartType = ExcelChartType.Column_Clustered;
2202+
2203+
//Set data range in the worksheet
2204+
chart.DataRange = sheet.Range["A1:C6"];
2205+
chart.IsSeriesInRows = false;
2206+
2207+
//Get Serie
2208+
IChartSerie serie1 = chart.Series[0];
2209+
IChartSerie serie2 = chart.Series[1];
2210+
2211+
//Set Datalabels
2212+
serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
2213+
serie2.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
2214+
serie1.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;
2215+
serie2.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;
2216+
2217+
//Gradient fill for serie1
2218+
ChartFillImpl chartFillImpl1 = serie1.SerieFormat.Fill as ChartFillImpl;
2219+
chartFillImpl1.FillType = ExcelFillType.Gradient;
2220+
chartFillImpl1.GradientColorType = ExcelGradientColor.MultiColor;
2221+
serie1.SerieFormat.Fill.GradientStyle = ExcelGradientStyle.Horizontal;
2222+
GradientStopImpl gradientStopImpl1 = new GradientStopImpl(new ColorObject(Color.FromArgb(0, 176, 240)), 50000, 100000);
2223+
GradientStopImpl gradientStopImpl2 = new GradientStopImpl(new ColorObject(Color.FromArgb(0, 112, 192)), 70000, 100000);
2224+
chartFillImpl1.GradientStops.GradientType = GradientType.Liniar;
2225+
chartFillImpl1.GradientStops.Add(gradientStopImpl1);
2226+
chartFillImpl1.GradientStops.Add(gradientStopImpl2);
2227+
2228+
//Gradient fill for serie2
2229+
ChartFillImpl chartFillImpl2 = serie2.SerieFormat.Fill as ChartFillImpl;
2230+
chartFillImpl2.FillType = ExcelFillType.Gradient;
2231+
chartFillImpl2.GradientColorType = ExcelGradientColor.MultiColor;
2232+
serie2.SerieFormat.Fill.GradientStyle = ExcelGradientStyle.Horizontal;
2233+
GradientStopImpl gradientStopImpl3 = new GradientStopImpl(new ColorObject(Color.FromArgb(244, 177, 131)), 40000, 100000);
2234+
GradientStopImpl gradientStopImpl4 = new GradientStopImpl(new ColorObject(Color.FromArgb(255, 102, 0)), 70000, 100000);
2235+
chartFillImpl2.GradientStops.GradientType = GradientType.Liniar;
2236+
chartFillImpl2.GradientStops.Add(gradientStopImpl3);
2237+
chartFillImpl2.GradientStops.Add(gradientStopImpl4);
2238+
2239+
//Set Legend
2240+
chart.HasLegend = true;
2241+
chart.Legend.Position = ExcelLegendPosition.Bottom;
2242+
2243+
//Positioning the chart in the worksheet
2244+
chart.TopRow = 8;
2245+
chart.LeftColumn = 1;
2246+
chart.BottomRow = 23;
2247+
chart.RightColumn = 8;
2248+
2249+
//Saving the workbook
2250+
FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write);
2251+
workbook.SaveAs(outputStream);
2252+
2253+
//Dispose streams
2254+
outputStream.Dispose();
2255+
inputStream.Dispose();
2256+
}
2257+
{% endhighlight %}
2258+
2259+
{% highlight c# tabtitle="C# [Windows-specific]" %}
2260+
using (ExcelEngine engine = new ExcelEngine())
2261+
{
2262+
IApplication application = engine.Excel;
2263+
application.DefaultVersion = ExcelVersion.Xlsx;
2264+
IWorkbook workbook = application.Workbooks.Open("../../Data/InputTemplate.xlsx");
2265+
IWorksheet sheet = workbook.Worksheets[0];
2266+
2267+
//Create a Chart
2268+
IChartShape chart = sheet.Charts.Add();
2269+
2270+
//Set Chart Type
2271+
chart.ChartType = ExcelChartType.Column_Clustered;
2272+
2273+
//Set data range in the worksheet
2274+
chart.DataRange = sheet.Range["A1:C6"];
2275+
chart.IsSeriesInRows = false;
2276+
2277+
//Get Serie
2278+
IChartSerie serie1 = chart.Series[0];
2279+
IChartSerie serie2 = chart.Series[1];
2280+
2281+
//Set Datalabels
2282+
serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
2283+
serie2.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
2284+
serie1.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;
2285+
serie2.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;
2286+
2287+
//Gradient fill for serie1
2288+
ChartFillImpl chartFillImpl1 = serie1.SerieFormat.Fill as ChartFillImpl;
2289+
chartFillImpl1.FillType = ExcelFillType.Gradient;
2290+
chartFillImpl1.GradientColorType = ExcelGradientColor.MultiColor;
2291+
serie1.SerieFormat.Fill.GradientStyle = ExcelGradientStyle.Horizontal;
2292+
GradientStopImpl gradientStopImpl1 = new GradientStopImpl(new ColorObject(Color.FromArgb(0, 176, 240)), 50000, 100000);
2293+
GradientStopImpl gradientStopImpl2 = new GradientStopImpl(new ColorObject(Color.FromArgb(0, 112, 192)), 70000, 100000);
2294+
chartFillImpl1.GradientStops.GradientType = GradientType.Liniar;
2295+
chartFillImpl1.GradientStops.Add(gradientStopImpl1);
2296+
chartFillImpl1.GradientStops.Add(gradientStopImpl2);
2297+
2298+
//Gradient fill for serie2
2299+
ChartFillImpl chartFillImpl2 = serie2.SerieFormat.Fill as ChartFillImpl;
2300+
chartFillImpl2.FillType = ExcelFillType.Gradient;
2301+
chartFillImpl2.GradientColorType = ExcelGradientColor.MultiColor;
2302+
serie2.SerieFormat.Fill.GradientStyle = ExcelGradientStyle.Horizontal;
2303+
GradientStopImpl gradientStopImpl3 = new GradientStopImpl(new ColorObject(Color.FromArgb(244, 177, 131)), 40000, 100000);
2304+
GradientStopImpl gradientStopImpl4 = new GradientStopImpl(new ColorObject(Color.FromArgb(255, 102, 0)), 70000, 100000);
2305+
chartFillImpl2.GradientStops.GradientType = GradientType.Liniar;
2306+
chartFillImpl2.GradientStops.Add(gradientStopImpl3);
2307+
chartFillImpl2.GradientStops.Add(gradientStopImpl4);
2308+
2309+
//Set Legend
2310+
chart.HasLegend = true;
2311+
chart.Legend.Position = ExcelLegendPosition.Bottom;
2312+
2313+
//Positioning the chart in the worksheet
2314+
chart.TopRow = 8;
2315+
chart.LeftColumn = 1;
2316+
chart.BottomRow = 23;
2317+
chart.RightColumn = 8;
2318+
2319+
//Saving the workbook in xlsx format
2320+
workbook.SaveAs("Output.xlsx");
2321+
}
2322+
{% endhighlight %}
2323+
2324+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
2325+
Using engine As New ExcelEngine()
2326+
Dim application As IApplication = engine.Excel
2327+
application.DefaultVersion = ExcelVersion.Xlsx
2328+
Dim workbook As IWorkbook = application.Workbooks.Open("../../Data/InputTemplate.xlsx")
2329+
Dim sheet As IWorksheet = workbook.Worksheets(0)
2330+
2331+
'Create a Chart
2332+
Dim chart As IChartShape = sheet.Charts.Add()
2333+
2334+
'Set Chart Type
2335+
chart.ChartType = ExcelChartType.Column_Clustered
2336+
2337+
'Set data range in the worksheet
2338+
chart.DataRange = sheet.Range("A1:C6")
2339+
chart.IsSeriesInRows = False
2340+
2341+
'Get Serie
2342+
Dim serie1 As IChartSerie = chart.Series(0)
2343+
Dim serie2 As IChartSerie = chart.Series(1)
2344+
2345+
'Set Datalabels
2346+
serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
2347+
serie2.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
2348+
serie1.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside
2349+
serie2.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside
2350+
2351+
'Gradient fill for serie1
2352+
Dim chartFillImpl1 As ChartFillImpl = TryCast(serie1.SerieFormat.Fill, ChartFillImpl)
2353+
chartFillImpl1.FillType = ExcelFillType.Gradient
2354+
chartFillImpl1.GradientColorType = ExcelGradientColor.MultiColor
2355+
serie1.SerieFormat.Fill.GradientStyle = ExcelGradientStyle.Horizontal
2356+
Dim gradientStopImpl1 As New GradientStopImpl(New ColorObject(Color.FromArgb(0, 176, 240)), 50000, 100000)
2357+
Dim gradientStopImpl2 As New GradientStopImpl(New ColorObject(Color.FromArgb(0, 112, 192)), 70000, 100000)
2358+
chartFillImpl1.GradientStops.GradientType = GradientType.Liniar
2359+
chartFillImpl1.GradientStops.Add(gradientStopImpl1)
2360+
chartFillImpl1.GradientStops.Add(gradientStopImpl2)
2361+
2362+
'Gradient fill for serie2
2363+
Dim chartFillImpl2 As ChartFillImpl = TryCast(serie2.SerieFormat.Fill, ChartFillImpl)
2364+
chartFillImpl2.FillType = ExcelFillType.Gradient
2365+
chartFillImpl2.GradientColorType = ExcelGradientColor.MultiColor
2366+
serie2.SerieFormat.Fill.GradientStyle = ExcelGradientStyle.Horizontal
2367+
Dim gradientStopImpl3 As New GradientStopImpl(New ColorObject(Color.FromArgb(244, 177, 131)), 40000, 100000)
2368+
Dim gradientStopImpl4 As New GradientStopImpl(New ColorObject(Color.FromArgb(255, 102, 0)), 70000, 100000)
2369+
chartFillImpl2.GradientStops.GradientType = GradientType.Liniar
2370+
chartFillImpl2.GradientStops.Add(gradientStopImpl3)
2371+
chartFillImpl2.GradientStops.Add(gradientStopImpl4)
2372+
2373+
'Set Legend
2374+
chart.HasLegend = True
2375+
chart.Legend.Position = ExcelLegendPosition.Bottom
2376+
2377+
'Positioning the chart in the worksheet
2378+
chart.TopRow = 8
2379+
chart.LeftColumn = 1
2380+
chart.BottomRow = 23
2381+
chart.RightColumn = 8
2382+
2383+
'Saving the workbook in xlsx format
2384+
workbook.SaveAs("Output.xlsx")
2385+
End Using
2386+
{% endhighlight %}
2387+
{% endtabs %}
2388+
2389+
A complete working example for applying gradient fill in chart series in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Create%20and%20Edit%20Charts/Gradient%20Fill/NET%20Standard/Gradient%20Fill).
2390+
21132391
## Applying 3D Formats
21142392

21152393
The following code example explains how to apply 3D settings such as rotation, side wall, back wall, and floor settings.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: How to convert xls document to xlsx format document |Syncfusion.
3+
description: This page explains how to convert xls document to xlsx format document using Syncfusion .NET Excel library (XlsIO).
4+
platform: file-formats
5+
control: XlsIO
6+
documentation: UG
7+
---
8+
9+
# How to convert xls document to xlsx format document?
10+
11+
The following code illustrates how to convert xls document to xlsx format document.
12+
13+
{% tabs %}
14+
{% highlight c# tabtitle="C# [Cross-platform]" %}
15+
using (ExcelEngine excelEngine = new ExcelEngine())
16+
{
17+
IApplication application = excelEngine.Excel;
18+
application.DefaultVersion = ExcelVersion.Xlsx;
19+
20+
//Loads an xls file
21+
FileStream fileStream = new FileStream("InputTemplate.xls", FileMode.Open, FileAccess.Read);
22+
IWorkbook workbook = application.Workbooks.Open(fileStream);
23+
24+
//Set the workbook version to xlsx
25+
workbook.Version = ExcelVersion.Xlsx;
26+
27+
//Saving the workbook as stream in xlsx format
28+
FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
29+
workbook.SaveAs(stream);
30+
stream.Dispose();
31+
}
32+
{% endhighlight %}
33+
34+
{% highlight c# tabtitle="C# [Windows-specific]" %}
35+
using (ExcelEngine engine = new ExcelEngine())
36+
{
37+
IApplication application = engine.Excel;
38+
application.DefaultVersion = ExcelVersion.Xlsx;
39+
40+
//Loads an xls file
41+
IWorkbook workbook = application.Workbooks.Open("InputTemplate.xls");
42+
43+
//Set the workbook version to xlsx
44+
workbook.Version = ExcelVersion.Xlsx;
45+
46+
//Saving the workbook in xlsx format
47+
workbook.SaveAs("Output.xlsx");
48+
}
49+
{% endhighlight %}
50+
51+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
52+
Using engine As ExcelEngine = New ExcelEngine()
53+
Dim application As IApplication = engine.Excel
54+
application.DefaultVersion = ExcelVersion.Xlsx
55+
56+
'Loads an xls file
57+
Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xls")
58+
59+
'Set the workbook version to xlsx
60+
workbook.Version = ExcelVersion.Xlsx;
61+
62+
'Saving the workbook in xlsx format
63+
workbook.SaveAs("Output.xlsx")
64+
End Using
65+
{% endhighlight %}
66+
{% endtabs %}

0 commit comments

Comments
 (0)