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.
Unfortunately, activation email could not send to your email. Please try again.

Chart export to excel

Thread ID:

Created:

Updated:

Platform:

Replies:

59536 Apr 16,2007 02:56 PM Apr 23,2007 04:04 AM Windows Forms 7
loading
Tags: Chart
Lan Mo
Asked On April 16, 2007 02:56 PM

Hi,
V4.4.0.51 & VS2003

I want to export line chart with secondary YAxes to excel. I found the excel has custom type: "Lines on 2 Axes". How can I setup excel chart to this type in XslIO?

I know in excel VBA, I can use following code to set "Lines on 2 Axes". Do you have similar method in XslIO?

ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"

Thanks,


Lan

// A new workbook with 1 worksheet is created.
IWorkbook chartBook = ExcelUtils.CreateWorkbook(1);
// create chart worksheet
IChart chart = chartBook.Charts.Add("Chart");
IWorksheet sheet = chartBook.Worksheets[ 0 ];
sheet.Name="Data";
chart.ChartType=ExcelChartType.Line; //!!!!!I need to set it as type "Lines on 2 Axes"

Melba Winshia [Syncfusion]
Replied On April 17, 2007 06:47 AM

Hi Lan,

You can export line chart with secondary YAxes to excel by using the following code snippets:

[C#]

//Display secondary axis.
chart.SecondaryValueAxis.IsMaxCross = false;
chart.SecondaryCategoryAxis.IsMaxCross = true;

Please refer the following sample which implements the above said feature:

http://websamples.syncfusion.com/samples/XlsIO.Windows/F59536/main.htm

Kindly let me know if you have any other questions.

Thanks,
Melba

Lan Mo
Replied On April 18, 2007 01:23 PM

Hi Melba,
Thanks for help. Your sample helps to solve the exporting line-type chart to excel. I got little issue when exporting column-type chart with seconary YAxes to excel. Please see my attached files. The column is 'STACKED' above another in excel instead of 'SIDE-BY-SIDE' in Syncfusion chart.
How can I export columns 'SIDE-BY-SIDE' ?
Thanks,
Lan

SecondYAxesBar.zip

Melba Winshia [Syncfusion]
Replied On April 19, 2007 09:51 AM

Hi Lan,

Thanks for the update.

If you have more than two series only it will be visible as 'SIDE-BY-SIDE' else it will be stacked. This is the behaviour of Excel also. Here is the sample for your reference:

http://websamples.syncfusion.com/samples/XlsIO.Windows/59536_1/main.htm

This is because we must have at least two series in a chart in order to display secondary axes and one series is needed for each axis (ie. for primary and Secondary) group. The output of XlsIO is same as Ms Excel. Here is the video clip for your reference (to create a chart in Ms Excel with secondary Axis- the output is same as XlsIO)

Default.zip

Please let me know if I am missing some thing.

Thanks,
Melba

Lan Mo
Replied On April 19, 2007 01:42 PM

Hi Melba,
Thanks for your samples and explaination.

For my situation, I only have two seriess and they have very different Y valus ranged so that I think I have to use the secondary YAxes. I've explored the excel chart a little bit and I found if I can setup the series' GAP WIDTH to 70, I can at lease see both STACKED series. Please see my attached image.

My question is:
How can I set the GAP WIDTH in XslIO?

Thanks,

Lan

charttoexcel.zip

Melba Winshia [Syncfusion]
Replied On April 20, 2007 06:30 AM

Hi Lan,

Thanks for the update.

You can set GAP WIDTH by using the GapWidth property. Please refer the following code snippets to achieve this:

[c#]

//Format DataSeries
IChartSerie chartSerie = chart.Series["Apples"];

// Gap width
chartSerie.SerieFormat.CommonSerieOptions.GapWidth = 50;

Kindly let me know if you have any other questions.

Thanks,
Melba

Lan Mo
Replied On April 20, 2007 03:00 PM

Hello Melba,
It works well.

I've set the secondary YAxes series to:
chartSerie.SerieFormat.CommonSerieOptions.GapWidth = 300 //default is 150

Now the two series are stacked together but with off-set width so we can see both of them.

Please see my attached exported excel for you info.

I realy appreciate your help.
Have a great day!


Lan

Untitled38.zip

Melba Winshia [Syncfusion]
Replied On April 23, 2007 04:04 AM

Hi Lan,

Thanks for the update.

Glad to hear that it works well. Kindly let me know if you have any other questions.

Thanks,
Melba


CONFIRMATION

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.

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.

;