From 1b9891fbf124b473a2137538ae08ddd6e675ef31 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Mon, 25 Sep 2023 13:53:32 +0530 Subject: [PATCH 1/7] 849268-ManualLayout-Adding Chart Elements using Manual Layout --- File-Formats/XlsIO/Working-with-Charts.md | 258 ++++++++++++++++++++++ 1 file changed, 258 insertions(+) diff --git a/File-Formats/XlsIO/Working-with-Charts.md b/File-Formats/XlsIO/Working-with-Charts.md index 2cb2c51b0..3881e75d1 100644 --- a/File-Formats/XlsIO/Working-with-Charts.md +++ b/File-Formats/XlsIO/Working-with-Charts.md @@ -2618,6 +2618,264 @@ End Using A complete working example explaining different chart elements in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Create%20and%20Edit%20Charts/Chart%20Elements). +### Manual Layout + +#### Positioning Chart Elements using Manual Layout + +The following code samples illustrate how to position the chart elements. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +//Manually positioning plot area +chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; +chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + +//Manually positioning legent area +chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Manually positioning plot area +chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; +chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + +//Manually positioning legent area +chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Manually positioning plot area +chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; +chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + +'Manually positioning chart legend +chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; +{% endhighlight %} + +#### Resizing Chart Elements using Manual Layout + +The following code samples illustrate how to resize chart elements such as plot area, title area, data labels and legend. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +//Manually resizing the data labels +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; +chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; + +//Manually resizing the chart title area +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; + +//Manually resizing chart plot area +chart.PlotArea.Layout.ManualLayout.Height = 0.59; +chart.PlotArea.Layout.ManualLayout.Width = 0.81; +chart.PlotArea.Layout.ManualLayout.Top = 0.18; +chart.PlotArea.Layout.ManualLayout.Left = 0.16; + +//Manually resizing chart legend area +chart.Legend.Layout.ManualLayout.Height = 0.07; +chart.Legend.Layout.ManualLayout.Width = 0.30; +chart.Legend.Layout.ManualLayout.Top = 0.87; +chart.Legend.Layout.ManualLayout.Left = 0.35; +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +//Manually resizing the data labels +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; +chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; + +//Manually resizing the chart title area +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; + +//Manually resizing chart plot area +chart.PlotArea.Layout.ManualLayout.Height = 0.59; +chart.PlotArea.Layout.ManualLayout.Width = 0.81; +chart.PlotArea.Layout.ManualLayout.Top = 0.18; +chart.PlotArea.Layout.ManualLayout.Left = 0.16; + +//Manually resizing chart legend area +chart.Legend.Layout.ManualLayout.Height = 0.07; +chart.Legend.Layout.ManualLayout.Width = 0.30; +chart.Legend.Layout.ManualLayout.Top = 0.87; +chart.Legend.Layout.ManualLayout.Left = 0.35; +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +'Manually resizing the data labels +chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 +chart.Series(0).DataPoints(2).DataLabels.Layout.ManualLayout.Top = 0 + +'Manually resizing the chart title area +chart.ChartTitleArea.Text = "Sample Chart" +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03 +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02 + +'Manually resizing chart plot area +chart.PlotArea.Layout.ManualLayout.Height = 0.59 +chart.PlotArea.Layout.ManualLayout.Width = 0.81 +chart.PlotArea.Layout.ManualLayout.Top = 0.18 +chart.PlotArea.Layout.ManualLayout.Left = 0.16 + +'Manually resizing chart legend area +chart.Legend.Layout.ManualLayout.Height = 0.07 +chart.Legend.Layout.ManualLayout.Width = 0.30 +chart.Legend.Layout.ManualLayout.Top = 0.87 +chart.Legend.Layout.ManualLayout.Left = 0.35 +{% endhighlight %} + +The complete code snippet illustrating the above options is shown below. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); + IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorksheet sheet = workbook.Worksheets[0]; + + IChartShape chart = sheet.Charts[0]; + + //Manually resizing the data labels + chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; + chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; + + //Manually resizing the chart title area + chart.ChartTitleArea.Text = "Sample Chart"; + chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; + chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; + + //Manually positioning plot area + chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; + chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + + //Manually resizing chart plot area + chart.PlotArea.Layout.ManualLayout.Height = 0.59; + chart.PlotArea.Layout.ManualLayout.Width = 0.81; + chart.PlotArea.Layout.ManualLayout.Top = 0.18; + chart.PlotArea.Layout.ManualLayout.Left = 0.16; + + //Manually positioning legent area + chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + + //Manually resizing chart legend area + chart.Legend.Layout.ManualLayout.Height = 0.07; + chart.Legend.Layout.ManualLayout.Width = 0.30; + chart.Legend.Layout.ManualLayout.Top = 0.87; + chart.Legend.Layout.ManualLayout.Left = 0.35; + + //Saving the workbook as stream + FileStream stream = new FileStream("ManualLayoutChart.xlsx", FileMode.Create, FileAccess.ReadWrite); + workbook.SaveAs(stream); + stream.Dispose(); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx", ExcelOpenType.Automatic); + IWorksheet sheet = workbook.Worksheets[0]; + + IChartShape chart = sheet.Charts[0]; + + //Manually resizing the data labels + chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; + chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; + + //Manually resizing the chart title area + chart.ChartTitleArea.Text = "Sample Chart"; + chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; + chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; + + //Manually positioning plot area + chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; + chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + + //Manually resizing chart plot area + chart.PlotArea.Layout.ManualLayout.Height = 0.59; + chart.PlotArea.Layout.ManualLayout.Width = 0.81; + chart.PlotArea.Layout.ManualLayout.Top = 0.18; + chart.PlotArea.Layout.ManualLayout.Left = 0.16; + + //Manually positioning legent area + chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + + //Manually resizing chart legend area + chart.Legend.Layout.ManualLayout.Height = 0.07; + chart.Legend.Layout.ManualLayout.Width = 0.30; + chart.Legend.Layout.ManualLayout.Top = 0.87; + chart.Legend.Layout.ManualLayout.Left = 0.35; + + //Saving the workbook + workbook.SaveAs("ManualLayoutChart.xlsx"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As ExcelEngine = New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + Dim inputStream As FileStream = New FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read) + Dim workbook As IWorkbook = application.Workbooks.Open(inputStream) + Dim sheet As IWorksheet = workbook.Worksheets(0) + Dim chart As IChartShape = sheet.Charts(0) + + 'Manually resizing the data labels + chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 + chart.Series(0).DataPoints(2).DataLabels.Layout.ManualLayout.Top = 0 + + 'Manually resizing the chart title area + chart.ChartTitleArea.Text = "Sample Chart" + chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03 + chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02 + + 'Manually positioning plot area + chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner + chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge + chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge + + 'Manually resizing chart plot area + chart.PlotArea.Layout.ManualLayout.Height = 0.59 + chart.PlotArea.Layout.ManualLayout.Width = 0.81 + chart.PlotArea.Layout.ManualLayout.Top = 0.18 + chart.PlotArea.Layout.ManualLayout.Left = 0.16 + + 'Manually positioning legent area + chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge + chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge + + 'Manually resizing chart legend area + chart.Legend.Layout.ManualLayout.Height = 0.07 + chart.Legend.Layout.ManualLayout.Width = 0.3 + chart.Legend.Layout.ManualLayout.Top = 0.87 + chart.Legend.Layout.ManualLayout.Left = 0.35 + + 'Saving the workbook as stream + Dim outputStream As FileStream = New FileStream("Chart.xlsx", FileMode.Create, FileAccess.Write) + workbook.SaveAs(outputStream) +End Using +{% endhighlight %} +{% endtabs %} + +A complete working example explaining different chart elements using Manual Layout in C# is present on [this GitHub page](). + N> In order to position the chart elements, plot area should be smaller than chart area. ## Explode a Pie Chart From e7e1a1107da972cb46589c05c6dd8eaebfdde4d5 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Tue, 26 Sep 2023 10:21:29 +0530 Subject: [PATCH 2/7] 849268-ManualLayout-Change the index of the datapoints --- File-Formats/XlsIO/Working-with-Charts.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/File-Formats/XlsIO/Working-with-Charts.md b/File-Formats/XlsIO/Working-with-Charts.md index 3881e75d1..d46c9e3db 100644 --- a/File-Formats/XlsIO/Working-with-Charts.md +++ b/File-Formats/XlsIO/Working-with-Charts.md @@ -2666,7 +2666,7 @@ The following code samples illustrate how to resize chart elements such as plot {% highlight c# tabtitle="C# [Cross-platform]" %} //Manually resizing the data labels chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; -chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; //Manually resizing the chart title area chart.ChartTitleArea.Text = "Sample Chart"; @@ -2689,7 +2689,7 @@ chart.Legend.Layout.ManualLayout.Left = 0.35; {% highlight c# tabtitle="C# [Windows-specific]" %} //Manually resizing the data labels chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; -chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; //Manually resizing the chart title area chart.ChartTitleArea.Text = "Sample Chart"; @@ -2712,7 +2712,7 @@ chart.Legend.Layout.ManualLayout.Left = 0.35; {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Manually resizing the data labels chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 -chart.Series(0).DataPoints(2).DataLabels.Layout.ManualLayout.Top = 0 +chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01 'Manually resizing the chart title area chart.ChartTitleArea.Text = "Sample Chart" @@ -2748,7 +2748,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Manually resizing the data labels chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; - chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; + chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; //Manually resizing the chart title area chart.ChartTitleArea.Text = "Sample Chart"; @@ -2795,7 +2795,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Manually resizing the data labels chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; - chart.Series[0].DataPoints[2].DataLabels.Layout.ManualLayout.Top = 0; + chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; //Manually resizing the chart title area chart.ChartTitleArea.Text = "Sample Chart"; @@ -2839,7 +2839,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine() 'Manually resizing the data labels chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 - chart.Series(0).DataPoints(2).DataLabels.Layout.ManualLayout.Top = 0 + chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01 'Manually resizing the chart title area chart.ChartTitleArea.Text = "Sample Chart" From 288f1ec783dc6249e4ceea00fb9759adf3f1aaa0 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Tue, 26 Sep 2023 19:36:18 +0530 Subject: [PATCH 3/7] 849268-ManualLayout-Modify the changes --- File-Formats/XlsIO/Working-with-Charts.md | 726 +++++++++++++--------- 1 file changed, 426 insertions(+), 300 deletions(-) diff --git a/File-Formats/XlsIO/Working-with-Charts.md b/File-Formats/XlsIO/Working-with-Charts.md index d46c9e3db..a1e54796a 100644 --- a/File-Formats/XlsIO/Working-with-Charts.md +++ b/File-Formats/XlsIO/Working-with-Charts.md @@ -2320,36 +2320,63 @@ The following code examples illustrate how to position the chart elements. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -//Manually positioning plot area +//Manually positioning chart plot area using Layout chart.PlotArea.Layout.LayoutTarget = LayoutTargets.inner; chart.PlotArea.Layout.LeftMode = LayoutModes.edge; chart.PlotArea.Layout.TopMode = LayoutModes.edge; -//Manually positioning chart legend +//Manually positioning chart plot area using Manual Layout +chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; +chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + +//Manually positioning chart legend area using Layout chart.Legend.Layout.LeftMode = LayoutModes.edge; chart.Legend.Layout.TopMode = LayoutModes.edge; + +//Manually positioning chart legend area using Manual Layout +chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Manually positioning plot area +//Manually positioning chart plot area using Layout chart.PlotArea.Layout.LayoutTarget = LayoutTargets.inner; chart.PlotArea.Layout.LeftMode = LayoutModes.edge; chart.PlotArea.Layout.TopMode = LayoutModes.edge; -//Manually positioning chart legend +//Manually positioning chart plot area using Manual Layout +chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; +chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + +//Manually positioning chart legend area using Layout chart.Legend.Layout.LeftMode = LayoutModes.edge; chart.Legend.Layout.TopMode = LayoutModes.edge; + +//Manually positioning chart legend area using Manual Layout +chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Manually positioning plot area +'Manually positioning chart plot area using Layout chart.PlotArea.Layout.LayoutTarget = LayoutTargets.inner chart.PlotArea.Layout.LeftMode = LayoutModes.edge chart.PlotArea.Layout.TopMode = LayoutModes.edge -'Manually positioning chart legend +'Manually positioning chart plot area using Manual Layout +chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; +chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + +'Manually positioning chart legend area using Layout chart.Legend.Layout.LeftMode = LayoutModes.edge chart.Legend.Layout.TopMode = LayoutModes.edge + +'Manually positioning chart legend area using Manual Layout +chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; +chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; {% endhighlight %} {% endtabs %} @@ -2395,45 +2422,171 @@ The following code examples illustrate how to resize chart elements such as plot {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -//Manually resizing chart plot area -chart.PlotArea.Layout.Left = 50; -chart.PlotArea.Layout.Top = 75; -chart.PlotArea.Layout.Width = 300; +//Manually resizing chart plot area using Layout +chart.PlotArea.Layout.Left = 70; +chart.PlotArea.Layout.Top = 40; +chart.PlotArea.Layout.Width = 280; chart.PlotArea.Layout.Height = 200; -//Manually resizing chart legend +//Manually resizing chart plot area using Manual Layout +chart.PlotArea.Layout.ManualLayout.Height = 0.80; +chart.PlotArea.Layout.ManualLayout.Width = 0.65; +chart.PlotArea.Layout.ManualLayout.Top = 0.03; +chart.PlotArea.Layout.ManualLayout.Left = -0.1; + +//Manually resizing chart legend area using Layout chart.Legend.Layout.Left = 400; chart.Legend.Layout.Top = 150; chart.Legend.Layout.Width = 150; chart.Legend.Layout.Height = 100; + +//Manually resizing chart legend area using Manual Layout +chart.Legend.Layout.ManualLayout.Height = 0.09; +chart.Legend.Layout.ManualLayout.Width = 0.30; +chart.Legend.Layout.ManualLayout.Top = 0.36; +chart.Legend.Layout.ManualLayout.Left = 0.68; + +// Manually resizing chart title area using Layout +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.Top = 10; +chart.ChartTitleArea.Layout.Left = 150; + +//Manually resizing chart title area using Manual Layout +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005; +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26; + +// Manually resizing axis title area using Layout +chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; +chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; + +//Manually resizing axis title area using Manual Layout +chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; +chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + +// Manually resizing data label area using Layout +chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; +chart.Series[0].DataPoints[0].DataLabels.Layout.Top = 0.01; + +//Manually resizing data label area using Manual Layout +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Manually resizing chart plot area -chart.PlotArea.Layout.Left = 50; -chart.PlotArea.Layout.Top = 75; -chart.PlotArea.Layout.Width = 300; +//Manually resizing chart plot area using Layout +chart.PlotArea.Layout.Left = 70; +chart.PlotArea.Layout.Top = 40; +chart.PlotArea.Layout.Width = 280; chart.PlotArea.Layout.Height = 200; -//Manually resizing chart legend +//Manually resizing chart plot area using Manual Layout +chart.PlotArea.Layout.ManualLayout.Height = 0.80; +chart.PlotArea.Layout.ManualLayout.Width = 0.65; +chart.PlotArea.Layout.ManualLayout.Top = 0.03; +chart.PlotArea.Layout.ManualLayout.Left = -0.1; + +//Manually resizing chart legend area using Layout chart.Legend.Layout.Left = 400; chart.Legend.Layout.Top = 150; chart.Legend.Layout.Width = 150; chart.Legend.Layout.Height = 100; + +//Manually resizing chart legend area using Manual Layout +chart.Legend.Layout.ManualLayout.Height = 0.09; +chart.Legend.Layout.ManualLayout.Width = 0.30; +chart.Legend.Layout.ManualLayout.Top = 0.36; +chart.Legend.Layout.ManualLayout.Left = 0.68; + +// Manually resizing chart title area using Layout +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.Top = 10; +chart.ChartTitleArea.Layout.Left = 150; + +//Manually resizing chart title area using Manual Layout +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005; +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26; + +// Manually resizing axis title area using Layout +chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; +chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; + +//Manually resizing axis title area using Manual Layout +chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; +chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + +// Manually resizing data label area using Layout +chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; +chart.Series[0].DataPoints[0].DataLabels.Layout.Top = 0.01; + +//Manually resizing data label area using Manual Layout +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; +chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Manually resizing chart plot area -chart.PlotArea.Layout.Left = 50 -chart.PlotArea.Layout.Top = 75 -chart.PlotArea.Layout.Width = 300 -chart.PlotArea.Layout.Height = 200 - -'Manually resizing chart legend -chart.Legend.Layout.Left = 400 -chart.Legend.Layout.Top = 150 -chart.Legend.Layout.Width = 150 -chart.Legend.Layout.Height = 100 +'Manually resizing chart plot area using Layout +chart.PlotArea.Layout.Left = 70; +chart.PlotArea.Layout.Top = 40; +chart.PlotArea.Layout.Width = 280; +chart.PlotArea.Layout.Height = 200; + +'Manually resizing chart plot area using Manual Layout +chart.PlotArea.Layout.ManualLayout.Height = 0.80; +chart.PlotArea.Layout.ManualLayout.Width = 0.65; +chart.PlotArea.Layout.ManualLayout.Top = 0.03; +chart.PlotArea.Layout.ManualLayout.Left = -0.1; + +'Manually resizing chart legend area using Layout +chart.Legend.Layout.Left = 400; +chart.Legend.Layout.Top = 150; +chart.Legend.Layout.Width = 150; +chart.Legend.Layout.Height = 100; + +'Manually resizing chart legend area using Manual Layout +chart.Legend.Layout.ManualLayout.Height = 0.09; +chart.Legend.Layout.ManualLayout.Width = 0.30; +chart.Legend.Layout.ManualLayout.Top = 0.36; +chart.Legend.Layout.ManualLayout.Left = 0.68; + +'Manually resizing chart title area using Layout +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.Top = 10; +chart.ChartTitleArea.Layout.Left = 150; + +'Manually resizing chart title area using Manual Layout +chart.ChartTitleArea.Text = "Sample Chart"; +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005; +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26; + +'Manually resizing axis title area using Layout +chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; +chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; + +'Manually resizing axis title area using Manual Layout +chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; +chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + +'Manually resizing data label area using Layout +chart.Series(0).DataPoints(0).DataLabels.Layout.Left = 0.09; +chart.Series(0).DataPoints(0).DataLabels.Layout.Top = 0.01; + +'Manually resizing data label area using Manual Layout +chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09; +chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01; {% endhighlight %} {% endtabs %} @@ -2449,7 +2602,7 @@ chart.ChartArea.Fill.Transparency = 0.9; {% highlight c# tabtitle="C# [Windows-specific]" %} //Applying transparency to chart area -chart.ChartArea.Fill.Transparency = 0.9; +chart.ChartArea.Fill.Transparency = 0.5; {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -2468,6 +2621,9 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Excel2013; FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); IWorkbook workbook = application.Workbooks.Open(inputStream); + + //Positioning chart elements using layout + //Access the first sheet in the workbook IWorksheet sheet = workbook.Worksheets[0]; IChartShape chart = sheet.Charts[0]; @@ -2478,12 +2634,12 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chart.RightColumn = 10; chart.BottomRow = 10; - //Manually positioning plot area + //Manually positioning chart plot area chart.PlotArea.Layout.LayoutTarget = LayoutTargets.inner; chart.PlotArea.Layout.LeftMode = LayoutModes.edge; chart.PlotArea.Layout.TopMode = LayoutModes.edge; - //Manually positioning chart legend + //Manually positioning chart legend area chart.Legend.Layout.LeftMode = LayoutModes.edge; chart.Legend.Layout.TopMode = LayoutModes.edge; IShape chartShape = chart as IShape; @@ -2495,19 +2651,92 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chartShape.Width = 500; //Manually resizing chart plot area - chart.PlotArea.Layout.Left = 50; - chart.PlotArea.Layout.Top = 75; - chart.PlotArea.Layout.Width = 300; + chart.PlotArea.Layout.Left = 70; + chart.PlotArea.Layout.Top = 40; + chart.PlotArea.Layout.Width = 280; chart.PlotArea.Layout.Height = 200; - //Manually resizing chart legend + //Manually resizing chart legend area chart.Legend.Layout.Left = 400; chart.Legend.Layout.Top = 150; - chart.Legend.Layout.Width = 200; + chart.Legend.Layout.Width = 150; chart.Legend.Layout.Height = 100; + // Manually resizing chart title area + chart.ChartTitleArea.Text = "Sample Chart"; + chart.ChartTitleArea.Layout.Top = 10; + chart.ChartTitleArea.Layout.Left = 150; + + // Manually resizing axis title area + chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; + chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; + chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; + chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; + + // Manually resizing data label area + chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; + chart.Series[0].DataPoints[0].DataLabels.Layout.Top = 0.01; + + //Applying transparency to chart area + chart.ChartArea.Fill.Transparency = 0.5; + + //Positioning chart elements using manual layout + //Access the second sheet in the workbook + IWorksheet sheet1 = workbook.Worksheets[1]; + + IChartShape chart1 = sheet1.Charts[0]; + + //Positioning chart in a worksheet + chart.TopRow = 5; + chart.LeftColumn = 5; + chart.RightColumn = 10; + chart.BottomRow = 10; + + //Manually positioning chart plot area + chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; + chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + + //Manually positioning chart legend area + chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + IShape chartShape1 = chart1 as IShape; + + //Set Height of the chart in pixels + chartShape.Height = 300; + + //Set Width of the chart + chartShape.Width = 500; + + //Manually resizing chart plot area + chart1.PlotArea.Layout.ManualLayout.Height = 0.80; + chart1.PlotArea.Layout.ManualLayout.Width = 0.65; + chart1.PlotArea.Layout.ManualLayout.Top = 0.03; + chart1.PlotArea.Layout.ManualLayout.Left = -0.1; + + //Manually resizing chart legend area + chart1.Legend.Layout.ManualLayout.Height = 0.09; + chart1.Legend.Layout.ManualLayout.Width = 0.30; + chart1.Legend.Layout.ManualLayout.Top = 0.36; + chart1.Legend.Layout.ManualLayout.Left = 0.68; + + //Manually resizing chart title area + chart1.ChartTitleArea.Text = "Sample Chart"; + chart1.ChartTitleArea.Layout.ManualLayout.Top = 0.005; + chart1.ChartTitleArea.Layout.ManualLayout.Left = 0.26; + + //Manually resizing axis title area + chart1.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; + chart1.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; + chart1.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; + chart1.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + + //Manually resizing data label area + chart1.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; + chart1.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; + //Applying transparency to chart area - chart.ChartArea.Fill.Transparency = 0.9; + chart1.ChartArea.Fill.Transparency = 0.5; //Saving the workbook as stream FileStream stream = new FileStream("Chart.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -2522,7 +2751,11 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); + + //Positioning chart elements using layout + //Access the first sheet in the workbook IWorksheet sheet = workbook.Worksheets[0]; + IChartShape chart = sheet.Charts[0]; //Positioning chart in a worksheet @@ -2531,12 +2764,12 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chart.RightColumn = 10; chart.BottomRow = 10; - //Manually positioning plot area + //Manually positioning chart plot area chart.PlotArea.Layout.LayoutTarget = LayoutTargets.inner; chart.PlotArea.Layout.LeftMode = LayoutModes.edge; chart.PlotArea.Layout.TopMode = LayoutModes.edge; - //Manually positioning chart legend + //Manually positioning chart legend area chart.Legend.Layout.LeftMode = LayoutModes.edge; chart.Legend.Layout.TopMode = LayoutModes.edge; IShape chartShape = chart as IShape; @@ -2548,19 +2781,92 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chartShape.Width = 500; //Manually resizing chart plot area - chart.PlotArea.Layout.Left = 50; - chart.PlotArea.Layout.Top = 75; - chart.PlotArea.Layout.Width = 300; + chart.PlotArea.Layout.Left = 70; + chart.PlotArea.Layout.Top = 40; + chart.PlotArea.Layout.Width = 280; chart.PlotArea.Layout.Height = 200; - //Manually resizing chart legend + //Manually resizing chart legend area chart.Legend.Layout.Left = 400; chart.Legend.Layout.Top = 150; - chart.Legend.Layout.Width = 200; + chart.Legend.Layout.Width = 150; chart.Legend.Layout.Height = 100; + // Manually resizing chart title area + chart.ChartTitleArea.Text = "Sample Chart"; + chart.ChartTitleArea.Layout.Top = 10; + chart.ChartTitleArea.Layout.Left = 150; + + // Manually resizing axis title area + chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; + chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; + chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; + chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; + + // Manually resizing data label area + chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; + chart.Series[0].DataPoints[0].DataLabels.Layout.Top = 0.01; + //Applying transparency to chart area - chart.ChartArea.Fill.Transparency = 0.9; + chart.ChartArea.Fill.Transparency = 0.5; + + //Positioning chart elements using manual layout + //Access the second sheet in the workbook + IWorksheet sheet1 = workbook.Worksheets[1]; + + IChartShape chart1 = sheet1.Charts[0]; + + //Positioning chart in a worksheet + chart.TopRow = 5; + chart.LeftColumn = 5; + chart.RightColumn = 10; + chart.BottomRow = 10; + + //Manually positioning chart plot area + chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; + chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + + //Manually positioning chart legend area + chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + IShape chartShape1 = chart1 as IShape; + + //Set Height of the chart in pixels + chartShape.Height = 300; + + //Set Width of the chart + chartShape.Width = 500; + + //Manually resizing chart plot area + chart1.PlotArea.Layout.ManualLayout.Height = 0.80; + chart1.PlotArea.Layout.ManualLayout.Width = 0.65; + chart1.PlotArea.Layout.ManualLayout.Top = 0.03; + chart1.PlotArea.Layout.ManualLayout.Left = -0.1; + + //Manually resizing chart legend area + chart1.Legend.Layout.ManualLayout.Height = 0.09; + chart1.Legend.Layout.ManualLayout.Width = 0.30; + chart1.Legend.Layout.ManualLayout.Top = 0.36; + chart1.Legend.Layout.ManualLayout.Left = 0.68; + + //Manually resizing chart title area + chart1.ChartTitleArea.Text = "Sample Chart"; + chart1.ChartTitleArea.Layout.ManualLayout.Top = 0.005; + chart1.ChartTitleArea.Layout.ManualLayout.Left = 0.26; + + //Manually resizing axis title area + chart1.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; + chart1.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; + chart1.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; + chart1.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + + //Manually resizing data label area + chart1.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; + chart1.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; + + //Applying transparency to chart area + chart1.ChartArea.Fill.Transparency = 0.5; workbook.SaveAs("Chart.xlsx"); } @@ -2569,9 +2875,14 @@ using (ExcelEngine excelEngine = new ExcelEngine()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel - application.DefaultVersion = ExcelVersion.Excel2013 - Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) + application.DefaultVersion = ExcelVersion.Xlsx + Dim inputStream As FileStream = New FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read) + Dim workbook As IWorkbook = application.Workbooks.Open(inputStream) + + 'Positioning chart elements using layout + 'Access the first sheet in the workbook Dim sheet As IWorksheet = workbook.Worksheets(0) + Dim chart As IChartShape = sheet.Charts(0) 'Positioning chart in a worksheet @@ -2580,12 +2891,12 @@ Using excelEngine As ExcelEngine = New ExcelEngine() chart.RightColumn = 10 chart.BottomRow = 10 - 'Manually positioning plot area + 'Manually positioning chart plot area chart.PlotArea.Layout.LayoutTarget = LayoutTargets.inner chart.PlotArea.Layout.LeftMode = LayoutModes.edge chart.PlotArea.Layout.TopMode = LayoutModes.edge - 'Manually positioning chart legend + 'Manually positioning chart legend area chart.Legend.Layout.LeftMode = LayoutModes.edge chart.Legend.Layout.TopMode = LayoutModes.edge Dim chartShape As IShape = TryCast(chart, IShape) @@ -2597,284 +2908,99 @@ Using excelEngine As ExcelEngine = New ExcelEngine() chartShape.Width = 500 'Manually resizing chart plot area - chart.PlotArea.Layout.Left = 50 - chart.PlotArea.Layout.Top = 75 - chart.PlotArea.Layout.Width = 300 + chart.PlotArea.Layout.Left = 70 + chart.PlotArea.Layout.Top = 40 + chart.PlotArea.Layout.Width = 280 chart.PlotArea.Layout.Height = 200 - 'Manually resizing chart legend + 'Manually resizing chart legend area chart.Legend.Layout.Left = 400 chart.Legend.Layout.Top = 150 - chart.Legend.Layout.Width = 200 + chart.Legend.Layout.Width = 150 chart.Legend.Layout.Height = 100 - 'Applying transparency to chart area - chart.ChartArea.Fill.Transparency = 0.9 - - workbook.SaveAs("Chart.xlsx") -End Using -{% endhighlight %} -{% endtabs %} - -A complete working example explaining different chart elements in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Create%20and%20Edit%20Charts/Chart%20Elements). - -### Manual Layout - -#### Positioning Chart Elements using Manual Layout - -The following code samples illustrate how to position the chart elements. - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} -//Manually positioning plot area -chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; -chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; -chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; - -//Manually positioning legent area -chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; -chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} -//Manually positioning plot area -chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; -chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; -chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; - -//Manually positioning legent area -chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; -chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Manually positioning plot area -chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; -chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; -chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; - -'Manually positioning chart legend -chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; -chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; -{% endhighlight %} - -#### Resizing Chart Elements using Manual Layout - -The following code samples illustrate how to resize chart elements such as plot area, title area, data labels and legend. - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} -//Manually resizing the data labels -chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; -chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; - -//Manually resizing the chart title area -chart.ChartTitleArea.Text = "Sample Chart"; -chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; -chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; - -//Manually resizing chart plot area -chart.PlotArea.Layout.ManualLayout.Height = 0.59; -chart.PlotArea.Layout.ManualLayout.Width = 0.81; -chart.PlotArea.Layout.ManualLayout.Top = 0.18; -chart.PlotArea.Layout.ManualLayout.Left = 0.16; - -//Manually resizing chart legend area -chart.Legend.Layout.ManualLayout.Height = 0.07; -chart.Legend.Layout.ManualLayout.Width = 0.30; -chart.Legend.Layout.ManualLayout.Top = 0.87; -chart.Legend.Layout.ManualLayout.Left = 0.35; -{% endhighlight %} - -{% highlight c# tabtitle="C# [Windows-specific]" %} -//Manually resizing the data labels -chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; -chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; - -//Manually resizing the chart title area -chart.ChartTitleArea.Text = "Sample Chart"; -chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; -chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; - -//Manually resizing chart plot area -chart.PlotArea.Layout.ManualLayout.Height = 0.59; -chart.PlotArea.Layout.ManualLayout.Width = 0.81; -chart.PlotArea.Layout.ManualLayout.Top = 0.18; -chart.PlotArea.Layout.ManualLayout.Left = 0.16; - -//Manually resizing chart legend area -chart.Legend.Layout.ManualLayout.Height = 0.07; -chart.Legend.Layout.ManualLayout.Width = 0.30; -chart.Legend.Layout.ManualLayout.Top = 0.87; -chart.Legend.Layout.ManualLayout.Left = 0.35; -{% endhighlight %} - -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Manually resizing the data labels -chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 -chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01 - -'Manually resizing the chart title area -chart.ChartTitleArea.Text = "Sample Chart" -chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03 -chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02 - -'Manually resizing chart plot area -chart.PlotArea.Layout.ManualLayout.Height = 0.59 -chart.PlotArea.Layout.ManualLayout.Width = 0.81 -chart.PlotArea.Layout.ManualLayout.Top = 0.18 -chart.PlotArea.Layout.ManualLayout.Left = 0.16 - -'Manually resizing chart legend area -chart.Legend.Layout.ManualLayout.Height = 0.07 -chart.Legend.Layout.ManualLayout.Width = 0.30 -chart.Legend.Layout.ManualLayout.Top = 0.87 -chart.Legend.Layout.ManualLayout.Left = 0.35 -{% endhighlight %} - -The complete code snippet illustrating the above options is shown below. - -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); - IWorksheet sheet = workbook.Worksheets[0]; - - IChartShape chart = sheet.Charts[0]; - - //Manually resizing the data labels - chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; - chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; + 'Manually resizing chart title area + chart.ChartTitleArea.Text = "Sample Chart" + chart.ChartTitleArea.Layout.Top = 10 + chart.ChartTitleArea.Layout.Left = 150 - //Manually resizing the chart title area - chart.ChartTitleArea.Text = "Sample Chart"; - chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; - chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; + 'Manually resizing axis title area + chart.PrimaryValueAxis.TitleArea.Layout.Left = 15 + chart.PrimaryValueAxis.TitleArea.Layout.Top = 20 + chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25 + chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20 - //Manually positioning plot area - chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; - chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + 'Manually resizing data label area + chart.Series(0).DataPoints(0).DataLabels.Layout.Left = 0.09 + chart.Series(0).DataPoints(0).DataLabels.Layout.Top = 0.01 - //Manually resizing chart plot area - chart.PlotArea.Layout.ManualLayout.Height = 0.59; - chart.PlotArea.Layout.ManualLayout.Width = 0.81; - chart.PlotArea.Layout.ManualLayout.Top = 0.18; - chart.PlotArea.Layout.ManualLayout.Left = 0.16; - - //Manually positioning legent area - chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + 'Applying transparency to chart area + chart.ChartArea.Fill.Transparency = 0.5; - //Manually resizing chart legend area - chart.Legend.Layout.ManualLayout.Height = 0.07; - chart.Legend.Layout.ManualLayout.Width = 0.30; - chart.Legend.Layout.ManualLayout.Top = 0.87; - chart.Legend.Layout.ManualLayout.Left = 0.35; + 'Positioning chart elements using manual layout + 'Access the second sheet in the workbook + Dim sheet1 As IWorksheet = workbook.Worksheets(0) - //Saving the workbook as stream - FileStream stream = new FileStream("ManualLayoutChart.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); -} -{% endhighlight %} + Dim chart1 As IChartShape = sheet.Charts(0) -{% highlight c# tabtitle="C# [Windows-specific]" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx", ExcelOpenType.Automatic); - IWorksheet sheet = workbook.Worksheets[0]; + //Positioning chart in a worksheet + chart1.TopRow = 5 + chart1.LeftColumn = 5 + chart1.RightColumn = 10 + chart1.BottomRow = 10 - IChartShape chart = sheet.Charts[0]; + //Manually positioning chart plot area + chart1.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner + chart1.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge + chart1.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge - //Manually resizing the data labels - chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; - chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; + //Manually positioning chart legend area + chart1.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge + chart1.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge + Dim chartShape1 As IShape = TryCast(chart1, IShape) - //Manually resizing the chart title area - chart.ChartTitleArea.Text = "Sample Chart"; - chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03; - chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02; + //Set Height of the chart in pixels + chartShape1.Height = 300 - //Manually positioning plot area - chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; - chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + //Set Width of the chart + chartShape1.Width = 500 //Manually resizing chart plot area - chart.PlotArea.Layout.ManualLayout.Height = 0.59; - chart.PlotArea.Layout.ManualLayout.Width = 0.81; - chart.PlotArea.Layout.ManualLayout.Top = 0.18; - chart.PlotArea.Layout.ManualLayout.Left = 0.16; - - //Manually positioning legent area - chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + chart1.PlotArea.Layout.ManualLayout.Height = 0.80 + chart1.PlotArea.Layout.ManualLayout.Width = 0.65 + chart1.PlotArea.Layout.ManualLayout.Top = 0.03 + chart1.PlotArea.Layout.ManualLayout.Left = -0.1 //Manually resizing chart legend area - chart.Legend.Layout.ManualLayout.Height = 0.07; - chart.Legend.Layout.ManualLayout.Width = 0.30; - chart.Legend.Layout.ManualLayout.Top = 0.87; - chart.Legend.Layout.ManualLayout.Left = 0.35; - - //Saving the workbook - workbook.SaveAs("ManualLayoutChart.xlsx"); -} -{% endhighlight %} + chart1.Legend.Layout.ManualLayout.Height = 0.09 + chart1.Legend.Layout.ManualLayout.Width = 0.30 + chart1.Legend.Layout.ManualLayout.Top = 0.36 + chart1.Legend.Layout.ManualLayout.Left = 0.68 + + 'Manually resizing chart title area + chart1.ChartTitleArea.Text = "Sample Chart" + chart1.ChartTitleArea.Layout.ManualLayout.Top = 0.005 + chart1.ChartTitleArea.Layout.ManualLayout.Left = 0.26 + + 'Manually resizing axis title area + chart1.PrimaryValueAxis.TitleArea.Layout.Left = 0.04 + chart1.PrimaryValueAxis.TitleArea.Layout.Top = 0.34 + chart1.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38 + chart1.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95 + + 'Manually resizing data label area + chart1.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 + chart1.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01 -{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -Using excelEngine As ExcelEngine = New ExcelEngine() - Dim application As IApplication = excelEngine.Excel - application.DefaultVersion = ExcelVersion.Xlsx - Dim inputStream As FileStream = New FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read) - Dim workbook As IWorkbook = application.Workbooks.Open(inputStream) - Dim sheet As IWorksheet = workbook.Worksheets(0) - Dim chart As IChartShape = sheet.Charts(0) - - 'Manually resizing the data labels - chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 - chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01 - - 'Manually resizing the chart title area - chart.ChartTitleArea.Text = "Sample Chart" - chart.ChartTitleArea.Layout.ManualLayout.Top = 0.03 - chart.ChartTitleArea.Layout.ManualLayout.Left = 0.02 - - 'Manually positioning plot area - chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner - chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge - chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge - - 'Manually resizing chart plot area - chart.PlotArea.Layout.ManualLayout.Height = 0.59 - chart.PlotArea.Layout.ManualLayout.Width = 0.81 - chart.PlotArea.Layout.ManualLayout.Top = 0.18 - chart.PlotArea.Layout.ManualLayout.Left = 0.16 - - 'Manually positioning legent area - chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge - chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge + 'Applying transparency to chart area + chart1.ChartArea.Fill.Transparency = 0.5 - 'Manually resizing chart legend area - chart.Legend.Layout.ManualLayout.Height = 0.07 - chart.Legend.Layout.ManualLayout.Width = 0.3 - chart.Legend.Layout.ManualLayout.Top = 0.87 - chart.Legend.Layout.ManualLayout.Left = 0.35 - - 'Saving the workbook as stream - Dim outputStream As FileStream = New FileStream("Chart.xlsx", FileMode.Create, FileAccess.Write) - workbook.SaveAs(outputStream) + workbook.SaveAs("Chart.xlsx") End Using {% endhighlight %} {% endtabs %} -A complete working example explaining different chart elements using Manual Layout in C# is present on [this GitHub page](). +A complete working example explaining different chart elements in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Create%20and%20Edit%20Charts/Chart%20Elements). N> In order to position the chart elements, plot area should be smaller than chart area. From cc996093a3c6eb59f7746d0519af1a1f286e74f2 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Tue, 26 Sep 2023 19:52:03 +0530 Subject: [PATCH 4/7] 849268-ManualLayout-Changes the alignment --- File-Formats/XlsIO/Working-with-Charts.md | 137 +++++++++++----------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/File-Formats/XlsIO/Working-with-Charts.md b/File-Formats/XlsIO/Working-with-Charts.md index a1e54796a..87cfa97af 100644 --- a/File-Formats/XlsIO/Working-with-Charts.md +++ b/File-Formats/XlsIO/Working-with-Charts.md @@ -2446,7 +2446,7 @@ chart.Legend.Layout.ManualLayout.Width = 0.30; chart.Legend.Layout.ManualLayout.Top = 0.36; chart.Legend.Layout.ManualLayout.Left = 0.68; -// Manually resizing chart title area using Layout +//Manually resizing chart title area using Layout chart.ChartTitleArea.Text = "Sample Chart"; chart.ChartTitleArea.Layout.Top = 10; chart.ChartTitleArea.Layout.Left = 150; @@ -2456,7 +2456,7 @@ chart.ChartTitleArea.Text = "Sample Chart"; chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005; chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26; -// Manually resizing axis title area using Layout +//Manually resizing axis title area using Layout chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; @@ -2468,7 +2468,7 @@ chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; -// Manually resizing data label area using Layout +//Manually resizing data label area using Layout chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; chart.Series[0].DataPoints[0].DataLabels.Layout.Top = 0.01; @@ -2502,7 +2502,7 @@ chart.Legend.Layout.ManualLayout.Width = 0.30; chart.Legend.Layout.ManualLayout.Top = 0.36; chart.Legend.Layout.ManualLayout.Left = 0.68; -// Manually resizing chart title area using Layout +//Manually resizing chart title area using Layout chart.ChartTitleArea.Text = "Sample Chart"; chart.ChartTitleArea.Layout.Top = 10; chart.ChartTitleArea.Layout.Left = 150; @@ -2512,7 +2512,7 @@ chart.ChartTitleArea.Text = "Sample Chart"; chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005; chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26; -// Manually resizing axis title area using Layout +//Manually resizing axis title area using Layout chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; @@ -2524,7 +2524,7 @@ chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; -// Manually resizing data label area using Layout +//Manually resizing data label area using Layout chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; chart.Series[0].DataPoints[0].DataLabels.Layout.Top = 0.01; @@ -2535,58 +2535,58 @@ chart.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Top = 0.01; {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Manually resizing chart plot area using Layout -chart.PlotArea.Layout.Left = 70; -chart.PlotArea.Layout.Top = 40; -chart.PlotArea.Layout.Width = 280; -chart.PlotArea.Layout.Height = 200; +chart.PlotArea.Layout.Left = 70 +chart.PlotArea.Layout.Top = 40 +chart.PlotArea.Layout.Width = 280 +chart.PlotArea.Layout.Height = 200 'Manually resizing chart plot area using Manual Layout -chart.PlotArea.Layout.ManualLayout.Height = 0.80; -chart.PlotArea.Layout.ManualLayout.Width = 0.65; -chart.PlotArea.Layout.ManualLayout.Top = 0.03; -chart.PlotArea.Layout.ManualLayout.Left = -0.1; +chart.PlotArea.Layout.ManualLayout.Height = 0.80 +chart.PlotArea.Layout.ManualLayout.Width = 0.65 +chart.PlotArea.Layout.ManualLayout.Top = 0.03 +chart.PlotArea.Layout.ManualLayout.Left = -0.1 'Manually resizing chart legend area using Layout -chart.Legend.Layout.Left = 400; -chart.Legend.Layout.Top = 150; -chart.Legend.Layout.Width = 150; -chart.Legend.Layout.Height = 100; +chart.Legend.Layout.Left = 400 +chart.Legend.Layout.Top = 150 +chart.Legend.Layout.Width = 150 +chart.Legend.Layout.Height = 100 'Manually resizing chart legend area using Manual Layout -chart.Legend.Layout.ManualLayout.Height = 0.09; -chart.Legend.Layout.ManualLayout.Width = 0.30; -chart.Legend.Layout.ManualLayout.Top = 0.36; -chart.Legend.Layout.ManualLayout.Left = 0.68; +chart.Legend.Layout.ManualLayout.Height = 0.09 +chart.Legend.Layout.ManualLayout.Width = 0.30 +chart.Legend.Layout.ManualLayout.Top = 0.36 +chart.Legend.Layout.ManualLayout.Left = 0.68 'Manually resizing chart title area using Layout -chart.ChartTitleArea.Text = "Sample Chart"; -chart.ChartTitleArea.Layout.Top = 10; -chart.ChartTitleArea.Layout.Left = 150; +chart.ChartTitleArea.Text = "Sample Chart" +chart.ChartTitleArea.Layout.Top = 10 +chart.ChartTitleArea.Layout.Left = 150 'Manually resizing chart title area using Manual Layout -chart.ChartTitleArea.Text = "Sample Chart"; -chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005; -chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26; +chart.ChartTitleArea.Text = "Sample Chart" +chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005 +chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26 'Manually resizing axis title area using Layout -chart.PrimaryValueAxis.TitleArea.Layout.Left = 15; -chart.PrimaryValueAxis.TitleArea.Layout.Top = 20; -chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; -chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; +chart.PrimaryValueAxis.TitleArea.Layout.Left = 15 +chart.PrimaryValueAxis.TitleArea.Layout.Top = 20 +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25 +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20 'Manually resizing axis title area using Manual Layout -chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; -chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; -chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; -chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; +chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04 +chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34 +chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38 +chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95 'Manually resizing data label area using Layout -chart.Series(0).DataPoints(0).DataLabels.Layout.Left = 0.09; -chart.Series(0).DataPoints(0).DataLabels.Layout.Top = 0.01; +chart.Series(0).DataPoints(0).DataLabels.Layout.Left = 0.09 +chart.Series(0).DataPoints(0).DataLabels.Layout.Top = 0.01 'Manually resizing data label area using Manual Layout -chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09; -chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01; +chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 +chart.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Top = 0.01 {% endhighlight %} {% endtabs %} @@ -2597,7 +2597,7 @@ The following code example explains how to apply transparency to chart area. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} //Applying transparency to chart area -chart.ChartArea.Fill.Transparency = 0.9; +chart.ChartArea.Fill.Transparency = 0.5; {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -2607,7 +2607,7 @@ chart.ChartArea.Fill.Transparency = 0.5; {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Applying transparency to chart area -chart.ChartArea.Fill.Transparency = 0.9 +chart.ChartArea.Fill.Transparency = 0.5 {% endhighlight %} {% endtabs %} @@ -2618,7 +2618,7 @@ The complete code snippet illustrating the above options is shown below. using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Excel2013; + application.DefaultVersion = ExcelVersion.Xlsx; FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); IWorkbook workbook = application.Workbooks.Open(inputStream); @@ -2687,26 +2687,26 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IChartShape chart1 = sheet1.Charts[0]; //Positioning chart in a worksheet - chart.TopRow = 5; - chart.LeftColumn = 5; - chart.RightColumn = 10; - chart.BottomRow = 10; + chart1.TopRow = 5; + chart1.LeftColumn = 5; + chart1.RightColumn = 10; + chart1.BottomRow = 10; //Manually positioning chart plot area - chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; - chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + chart1.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; + chart1.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart1.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; //Manually positioning chart legend area - chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + chart1.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart1.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; IShape chartShape1 = chart1 as IShape; //Set Height of the chart in pixels - chartShape.Height = 300; + chartShape1.Height = 300; //Set Width of the chart - chartShape.Width = 500; + chartShape1.Width = 500; //Manually resizing chart plot area chart1.PlotArea.Layout.ManualLayout.Height = 0.80; @@ -2749,7 +2749,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Excel2013; + application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); //Positioning chart elements using layout @@ -2817,26 +2817,26 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IChartShape chart1 = sheet1.Charts[0]; //Positioning chart in a worksheet - chart.TopRow = 5; - chart.LeftColumn = 5; - chart.RightColumn = 10; - chart.BottomRow = 10; + chart1.TopRow = 5; + chart1.LeftColumn = 5; + chart1.RightColumn = 10; + chart1.BottomRow = 10; //Manually positioning chart plot area - chart.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; - chart.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; + chart1.PlotArea.Layout.ManualLayout.LayoutTarget = LayoutTargets.inner; + chart1.PlotArea.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart1.PlotArea.Layout.ManualLayout.TopMode = LayoutModes.edge; //Manually positioning chart legend area - chart.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; - chart.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; + chart1.Legend.Layout.ManualLayout.LeftMode = LayoutModes.edge; + chart1.Legend.Layout.ManualLayout.TopMode = LayoutModes.edge; IShape chartShape1 = chart1 as IShape; //Set Height of the chart in pixels - chartShape.Height = 300; + chartShape1.Height = 300; //Set Width of the chart - chartShape.Width = 500; + chartShape1.Width = 500; //Manually resizing chart plot area chart1.PlotArea.Layout.ManualLayout.Height = 0.80; @@ -2876,8 +2876,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) Using excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel application.DefaultVersion = ExcelVersion.Xlsx - Dim inputStream As FileStream = New FileStream("../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read) - Dim workbook As IWorkbook = application.Workbooks.Open(inputStream) + Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic) 'Positioning chart elements using layout 'Access the first sheet in the workbook @@ -2935,7 +2934,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine() chart.Series(0).DataPoints(0).DataLabels.Layout.Top = 0.01 'Applying transparency to chart area - chart.ChartArea.Fill.Transparency = 0.5; + chart.ChartArea.Fill.Transparency = 0.5 'Positioning chart elements using manual layout 'Access the second sheet in the workbook From ad3f6ed69dc440b60b2d968573df078166b68b02 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Tue, 26 Sep 2023 20:15:42 +0530 Subject: [PATCH 5/7] 849268-ManualLayout-Modify axis title area --- File-Formats/XlsIO/Working-with-Charts.md | 48 +++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/File-Formats/XlsIO/Working-with-Charts.md b/File-Formats/XlsIO/Working-with-Charts.md index 87cfa97af..5eaa23fae 100644 --- a/File-Formats/XlsIO/Working-with-Charts.md +++ b/File-Formats/XlsIO/Working-with-Charts.md @@ -2463,10 +2463,10 @@ chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; //Manually resizing axis title area using Manual Layout -chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; -chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; -chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; -chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; +chart.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Left = 0.04; +chart.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Top = 0.34; +chart.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Left = 0.38; +chart.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Top = 0.95; //Manually resizing data label area using Layout chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; @@ -2519,10 +2519,10 @@ chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25; chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20; //Manually resizing axis title area using Manual Layout -chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; -chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; -chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; -chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; +chart.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Left = 0.04; +chart.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Top = 0.34; +chart.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Left = 0.38; +chart.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Top = 0.95; //Manually resizing data label area using Layout chart.Series[0].DataPoints[0].DataLabels.Layout.Left = 0.09; @@ -2575,10 +2575,10 @@ chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 25 chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 20 'Manually resizing axis title area using Manual Layout -chart.PrimaryValueAxis.TitleArea.Layout.Left = 0.04 -chart.PrimaryValueAxis.TitleArea.Layout.Top = 0.34 -chart.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38 -chart.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95 +chart.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Left = 0.04 +chart.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Top = 0.34 +chart.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Left = 0.38 +chart.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Top = 0.95 'Manually resizing data label area using Layout chart.Series(0).DataPoints(0).DataLabels.Layout.Left = 0.09 @@ -2726,10 +2726,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chart1.ChartTitleArea.Layout.ManualLayout.Left = 0.26; //Manually resizing axis title area - chart1.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; - chart1.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; - chart1.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; - chart1.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + chart1.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Left = 0.04; + chart1.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Top = 0.34; + chart1.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Left = 0.38; + chart1.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Top = 0.95; //Manually resizing data label area chart1.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; @@ -2856,10 +2856,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chart1.ChartTitleArea.Layout.ManualLayout.Left = 0.26; //Manually resizing axis title area - chart1.PrimaryValueAxis.TitleArea.Layout.Left = 0.04; - chart1.PrimaryValueAxis.TitleArea.Layout.Top = 0.34; - chart1.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38; - chart1.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95; + chart1.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Left = 0.04; + chart1.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Top = 0.34; + chart1.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Left = 0.38; + chart1.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Top = 0.95; //Manually resizing data label area chart1.Series[0].DataPoints[0].DataLabels.Layout.ManualLayout.Left = 0.09; @@ -2982,10 +2982,10 @@ Using excelEngine As ExcelEngine = New ExcelEngine() chart1.ChartTitleArea.Layout.ManualLayout.Left = 0.26 'Manually resizing axis title area - chart1.PrimaryValueAxis.TitleArea.Layout.Left = 0.04 - chart1.PrimaryValueAxis.TitleArea.Layout.Top = 0.34 - chart1.PrimaryCategoryAxis.TitleArea.Layout.Left = 0.38 - chart1.PrimaryCategoryAxis.TitleArea.Layout.Top = 0.95 + chart1.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Left = 0.04 + chart1.PrimaryValueAxis.TitleArea.Layout.ManualLayout.Top = 0.34 + chart1.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Left = 0.38 + chart1.PrimaryCategoryAxis.TitleArea.Layout.ManualLayout.Top = 0.95 'Manually resizing data label area chart1.Series(0).DataPoints(0).DataLabels.Layout.ManualLayout.Left = 0.09 From dc4a3ee0d05ebb6a7ca55c629780f1795ad5dc0f Mon Sep 17 00:00:00 2001 From: Srihariharan Date: Thu, 28 Sep 2023 10:27:03 +0530 Subject: [PATCH 6/7] 848740_UG_live_error : added proper highlight tag. --- File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md b/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md index f3303c374..a7e98a474 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md @@ -586,7 +586,7 @@ To resolve this issue, we can install the chromium using the docker file and set Docker File:

{% tabs %} -{% highlight} +{% highlight c# tabtitle="C#" %} FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base @@ -612,7 +612,7 @@ Docker File:

Code snippet: -{% highlight} +{% highlight c# tabtitle="C#" %} BlinkConverterSettings settings = new BlinkConverterSettings(); @@ -620,8 +620,6 @@ Code snippet: settings.BlinkPath = @"/usr/lib/chromium/chromium"; - - {% endhighlight %} {% endtabs %} From fae654da650a84226c7626b58b24fc86bf9fb4c0 Mon Sep 17 00:00:00 2001 From: AkashArul26 <95226047+AkashArul26@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:26:25 +0530 Subject: [PATCH 7/7] Added the Presentation to PDF video in Presentation-to-PDF.md Added the Presentation to PDF video in Presentation-to-PDF.md --- File-Formats/Presentation/Presentation-to-PDF.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/File-Formats/Presentation/Presentation-to-PDF.md b/File-Formats/Presentation/Presentation-to-PDF.md index b740f01a5..556f6e98f 100644 --- a/File-Formats/Presentation/Presentation-to-PDF.md +++ b/File-Formats/Presentation/Presentation-to-PDF.md @@ -12,6 +12,9 @@ PowerPoint allows you to convert an entire Presentation or a single slide into P * [Assemblies Information](https://help.syncfusion.com/file-formats/presentation/assemblies-required) * [NuGet Information](https://help.syncfusion.com/file-formats/presentation/nuget-packages-required#converting-powerpoint-presentation-into-pdf) +To quickly start converting a PowerPoint Presentation to a PDF using .NET PowerPoint libray, please check out this video: +{% youtube "https://www.youtube.com/watch?v=nytscOICpWk" %} + [PresentationToPdfConverter](https://help.syncfusion.com/cr/file-formats/Syncfusion.PresentationToPdfConverter.PresentationToPdfConverter.html) class is responsible for converting an entire Presentation or a slide into PDF. The following code example demonstrates how to convert a PowerPoint presentation to PDF. {% tabs %}