We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Switch Row/Column (switch axes) in xlsio chart

Thread ID:





117602 Nov 14,2014 08:36 AM UTC Nov 18,2014 06:16 AM UTC WinForms 1
Tags: XlsIO
Pankaj Sharma
Asked On November 14, 2014 08:36 AM UTC

I am looking for a way to switch between axes of the chart being generated with XlsIO library. 

Basically, I am using an excel template to create new sheets and populate some data to them accordingly. I am able to do everything, but somehow the axes don't come-up the way I want. I want a way to simply do what a (Switch Row/Column button in Excel.exe) would do to the generated chart i.e. switch axes of the chart. Or may be control the axis programatically, and switch between X axis and Y axis with code.

Though, I have a solution that I can generate the data for the chart as Transpose of what I am currently generating, but it seems to be a very big deal and almost impossible to change the orientation (transposed) of the data now.

Here is my code:

IChartShapes cs = ws.Charts; // ws is the worksheet being generated
foreach (IChart cs1 in cs)
    string strCName = cs1.Name;
    IRange rngs = ws.Range[cs1.Name]; //chart name and named range are the same
    cs1.PrimaryValueAxis.Font.Size = 4;
    cs1.PrimaryCategoryAxis.Font.Size = 4;
    cs1.DisplayBlanksAs = ExcelChartPlotEmpty.NotPlotted;
    cs1.DataRange = rngs;
    IChartCategoryAxis csa = cs1.PrimaryCategoryAxis;
    csa.CategoryLabels.WrapText = true;

Any help will be much appreciated.

Vikas Sekar [Syncfusion]
Replied On November 18, 2014 06:16 AM UTC

Hi Pankaj,


Thanks for using Syncfusion Products.

In XlsIO there is an boolean property “IsSeriesRow” for chart, which will swap chart series. We have attached a sample and shared the code snippets for your reference.


Code Snippets:

IChartShapes chartShapes = worksheet.Charts;


            foreach (IChart charShape in chartShapes)


                string strCName = charShape.Name;

                IRange rngs = worksheet.Range[charShape.Name];


                charShape.IsSeriesInRows = false; // swaps the series



Sample Link:  http://www.syncfusion.com/downloads/support/directtrac/general/Sample1128645809.zip


Please let us know this fulfills your requirement and if you need  any clarification.





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon