locked
Axis type as Data in C#? RRS feed

  • Question

  • Hello everybody.

    I created Line Chart in Excel 2010 with two serieses of data with common X [Horizontal] axis as a Percentage. It plots the chart but it's a little mess there, but when right click the % axis >Format and choose Type as Data, it fixes the chart and it's all good, my question is how can i do that effect [Type as Data {Rather than Text or Auto}] programatically using C# ? I check the Axis properties and .Type have xlValues / xlCategory and xlSeriesAxis but nothing like the UI options of Auto / Text / Data.

    So how can make series Type as Data with C#?

    Thanks ahead and have a nice day.

    //------------

    Update / BTW i use Excel 2010 14.0.7 x64

    Hi.. So i tried some things, and as i was thinking it's not that [DateFormat], The property is Date indeed, right under Axis Type on Axis Format when right clicking the X axis labels, but i can't find it anywhere on the Axis object, at first, the chart loox like this:

    hen right clicking the X axis choosing Axis Format, then under the Axis Type field, choosing Date brings this:

     Which is what i need and it's good, Maybe helps 2 mention, that one series is longer in rows than the other, as implied on the first chart, but they both are on the same percentage scale.. All i need is to choose the that Date property for the Axis Format via C#... 



    • Edited by YakirCohen Friday, December 5, 2014 9:29 PM
    Sunday, October 26, 2014 8:39 PM

Answers

  • I am not familiar with a Data number format.. I think you mean Date...

    In VBA you would do 

    ActiveChart.Axes(xlCategory).TickLabels.NumberFormat = "dd/mm/yyyy"

    in C# you are following the same Object Model...

    Grab the chart -> http://msdn.microsoft.com/en-us/library/Microsoft.Office.Interop.Excel.Chart(v=office.15).aspx

    Get the axes -> http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._chart.axes(v=office.15).aspx

    then you should have an intelli-sense for .TickLabels property and then .NumberFormat



    • Marked as answer by YakirCohen Monday, October 27, 2014 9:46 AM
    Monday, October 27, 2014 8:16 AM

All replies

  • I am not familiar with a Data number format.. I think you mean Date...

    In VBA you would do 

    ActiveChart.Axes(xlCategory).TickLabels.NumberFormat = "dd/mm/yyyy"

    in C# you are following the same Object Model...

    Grab the chart -> http://msdn.microsoft.com/en-us/library/Microsoft.Office.Interop.Excel.Chart(v=office.15).aspx

    Get the axes -> http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._chart.axes(v=office.15).aspx

    then you should have an intelli-sense for .TickLabels property and then .NumberFormat



    • Marked as answer by YakirCohen Monday, October 27, 2014 9:46 AM
    Monday, October 27, 2014 8:16 AM
  • Yeh you right it is Date Type and not Data, missed that.. i'll try to figure it out from here, thanks though..
    Monday, October 27, 2014 9:49 AM
  • Hi.. So i tries some things, and as i was thinking it's not that [DateFormat], The property is Date indeed, right under Axis Type on Axis Format when right clicking the X axis labels, but i can't find it anywhere on the Axis object, at first, the chart loox like this:


    Then right clicking the X axis choosing Axis Format, then under the Axis Type field, choosing Date brings this:

     Which is what i need and it's good, Maybe helps 2 mention, that one series is longer in rows than the other, as implied on the first chart, but they both are on the same percentage scale.. All i need is to choose the that Date property for the Axis Format via C#... 

     

    Monday, October 27, 2014 10:35 AM