From b77a54e8734787fe8b17067bc0573cf29db186b1 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Fri, 8 Mar 2024 10:00:48 +0530 Subject: [PATCH 1/2] 874530-LogBase-FAQ --- File-Formats-toc.html | 1 + File-Formats/XlsIO/FAQ.md | 3 +- ...thmic-scale-for-chart-in-excel-document.md | 106 ++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 File-Formats/XlsIO/faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document.md diff --git a/File-Formats-toc.html b/File-Formats-toc.html index 8be491b44..e776c6cec 100644 --- a/File-Formats-toc.html +++ b/File-Formats-toc.html @@ -1675,6 +1675,7 @@
  • How to set rounded corner for chart in Excel document
  • How to find and replace text in hyperlinks
  • How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?
  • +
  • How to set Logarithmic axis for chart in Excel document?
  • diff --git a/File-Formats/XlsIO/FAQ.md b/File-Formats/XlsIO/FAQ.md index b7f8315c7..d11bacab9 100644 --- a/File-Formats/XlsIO/FAQ.md +++ b/File-Formats/XlsIO/FAQ.md @@ -80,4 +80,5 @@ The frequently asked questions in Essential XlsIO are listed below. * [How to vary colors by point for line and column chart?](faqs/how-to-vary-colors-by-point-for-line-and-column-chart) * [How to upload a file to Azure blob and download as stream?](faqs/how-to-upload-a-file-to-azure-blob-and-download-as-stream) * [How to find and replace text in hyperlinks](faqs/how-to-find-and-replace-text-in-hyperlinks) -* [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) \ No newline at end of file +* [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) +* [How to set Logarithmic axis for chart in Excel document](faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document) \ No newline at end of file diff --git a/File-Formats/XlsIO/faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document.md b/File-Formats/XlsIO/faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document.md new file mode 100644 index 000000000..480968fba --- /dev/null +++ b/File-Formats/XlsIO/faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document.md @@ -0,0 +1,106 @@ +--- +title: How to set Logarithmic axis for chart in Excel document | Syncfusion +description: Code example to set Logarithmic axis for chart in Excel document using Syncfusion .NET Excel library (XlsIO). +platform: file-formats +control: XlsIO +documentation: UG +--- + +# How to set Logarithmic axis for chart in Excel document? + +The following code snippet shows how to set Logarithmic axis for chart in Excel document. + +{% 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, ExcelOpenType.Automatic); + IWorksheet sheet = workbook.Worksheets[0]; + + //Create a Chart + IChartShape chart = sheet.Charts.Add(); + + //Set Chart Type + chart.ChartType = ExcelChartType.Column_Clustered; + + //Set data range in the worksheet + chart.DataRange = sheet.Range["A1:C6"]; + + //Set chart value axis + IChartValueAxis valueAxis = chart.PrimaryValueAxis; + + //Set IsLogScale and log base + valueAxis.IsLogScale = true; + valueAxis.LogBase = 10; + + //Saving the workbook + FileStream outputStream = new FileStream("Chart.xlsx", FileMode.Create, FileAccess.Write); + workbook.SaveAs(outputStream); + + //Dispose streams + outputStream.Dispose(); + inputStream.Dispose(); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Excel2013; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx", ExcelOpenType.Automatic); + IWorksheet sheet = workbook.Worksheets[0]; + + //Create a Chart + IChartShape chart = sheet.Charts.Add(); + + //Set Chart Type + chart.ChartType = ExcelChartType.Column_Clustered; + + //Set data range in the worksheet + chart.DataRange = sheet.Range["A1:C6"]; + + //Set chart value axis + IChartValueAxis valueAxis = chart.PrimaryValueAxis; + + //Set IsLogScale and log base + valueAxis.IsLogScale = true; + valueAxis.LogBase = 10; + + //Saving the workbook + workbook.SaveAs("Chart.xlsx"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} +Using excelEngine As New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Xlsx + Dim workbook As IWorkbook = application.Workbooks.Open(InputTemplate.xlsx", ExcelOpenType.Automatic) + Dim sheet As IWorksheet = workbook.Worksheets(0) + + ' Create a Chart + Dim chart As IChartShape = sheet.Charts.Add() + + ' Set Chart Type + chart.ChartType = ExcelChartType.Column_Clustered + + ' Set data range in the worksheet + chart.DataRange = sheet.Range("A1:C6") + + ' Set chart value axis + Dim valueAxis As IChartValueAxis = chart.PrimaryValueAxis + + ' Set IsLogScale and log base + valueAxis.IsLogScale = True + valueAxis.LogBase = 10 + + ' Saving the workbook + workbook.SaveAs(outputStream) + +End Using +{% endhighlight %} +{% endtabs %} \ No newline at end of file From f09ed1c1f02ff7f1e94a6e6563e4b163df93242a Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Fri, 8 Mar 2024 10:11:14 +0530 Subject: [PATCH 2/2] 874530-LogBase-FAQ --- File-Formats-toc.html | 2 +- File-Formats/XlsIO/FAQ.md | 2 +- ... how-to-set-logarithmic-axis-for-chart-in-excel-document.md} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename File-Formats/XlsIO/faqs/{how-to-set-logarithmic-scale-for-chart-in-excel-document.md => how-to-set-logarithmic-axis-for-chart-in-excel-document.md} (100%) diff --git a/File-Formats-toc.html b/File-Formats-toc.html index e776c6cec..3b9141560 100644 --- a/File-Formats-toc.html +++ b/File-Formats-toc.html @@ -1675,7 +1675,7 @@
  • How to set rounded corner for chart in Excel document
  • How to find and replace text in hyperlinks
  • How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?
  • -
  • How to set Logarithmic axis for chart in Excel document?
  • +
  • How to set Logarithmic axis for chart in Excel document?
  • diff --git a/File-Formats/XlsIO/FAQ.md b/File-Formats/XlsIO/FAQ.md index d11bacab9..87104604d 100644 --- a/File-Formats/XlsIO/FAQ.md +++ b/File-Formats/XlsIO/FAQ.md @@ -81,4 +81,4 @@ The frequently asked questions in Essential XlsIO are listed below. * [How to upload a file to Azure blob and download as stream?](faqs/how-to-upload-a-file-to-azure-blob-and-download-as-stream) * [How to find and replace text in hyperlinks](faqs/how-to-find-and-replace-text-in-hyperlinks) * [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) -* [How to set Logarithmic axis for chart in Excel document](faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document) \ No newline at end of file +* [How to set Logarithmic axis for chart in Excel document](faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document) \ No newline at end of file diff --git a/File-Formats/XlsIO/faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document.md b/File-Formats/XlsIO/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document.md similarity index 100% rename from File-Formats/XlsIO/faqs/how-to-set-logarithmic-scale-for-chart-in-excel-document.md rename to File-Formats/XlsIO/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document.md