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

Exporting a chart with DateTime on x axis

Thread ID:





94592 May 21,2010 05:31 PM UTC May 24,2010 09:24 AM UTC WinForms 1
Tags: XlsIO
Farman Samee
Asked On May 21, 2010 05:31 PM UTC


I am exporting charts where the category axis is always of DateTime type. I would like to set the maximum/ minimum values on the category axis, but the properties


only allow double values to be set. How can I set these for a DateTime axis?

Also, rather than letting Syncfusion/Excel pick the category axis markings arbitrarily, is it possible to force a more sensible system
(e.g. if my x axis spans 20 years, it is sensible to show the first day of each year along the x axis). This won't always happen depending on e.g. my first plotted date. I don't want to insert all category labels manually though!


Geetha M [Syncfusion]
Replied On May 24, 2010 09:24 AM UTC


Thank you for your interest in Syncfusion products.

Currently it is not possible to set minimum value and maximum value. However, you can manipulate the labels and use them at IChartSerie.CategoryLabels property. You can manipulate the values for the CategoryAxis and place them inside the sheet (for example the first day of the year if the actual range spans 20 years).

// Create Categorylabels and assign it.
sheet["D1"].DateTime = new DateTime(1989, 1, 1);
sheet["A4:A23"].CopyTo(sheet["D2"], ExcelCopyRangeOptions.All);
sheet["D22"].DateTime = new DateTime(2010, 1, 1);

IChartSerie serie = chartShape.Series[0];
serie.CategoryLabels = sheet["D1:D22"];

// Set the date format
chartShape.PrimaryCategoryAxis.NumberFormat = "ddd, yy";

I have placed the sample in the link below.

Please try this and let me know if you have any questions.



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