Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions File-Formats-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,7 @@
<li><a href="/file-formats/xlsio/faqs/how-to-set-rounded-corner-for-chart-in-excel-document">How to set rounded corner for chart in Excel document</a></li>
<li><a href="/file-formats/xlsio/faqs/how-to-find-and-replace-text-in-hyperlinks">How to find and replace text in hyperlinks</a></li>
<li><a href="/file-formats/xlsio/faqs/how-to-fix-the-argument-out-of-range-exception-when-accessing-a-large-number-of-rows-and-columns">How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?</a></li>
<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>
</ul>
</li>
</ul>
Expand Down
3 changes: 2 additions & 1 deletion File-Formats/XlsIO/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* [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-axis-for-chart-in-excel-document)
Original file line number Diff line number Diff line change
@@ -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 %}