Wanting to format excel chart axis dates

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Part of a Stock Charting app I am making involves creating a spreadsheet with a chart. ALl is well except that the Horizontal axis of dates is displayed poorly in some circumstances. If the user selects "monthly" as the sampling frequency, the chart shows
the date as the first day of each month, even if the underlying data is not the first day. Id rather format it as:
Jan-07, Feb-07, Mar-07 etc - I can do this manually after the sheet is done but it is preferable to set it in advance. Any information would be great, so far searches are not helping. Chart Code Follows:
<pre class="prettyprint lang-vb Dim chartPage As Microsoft.Office.Interop.Excel.Chart
Dim xlCharts As Microsoft.Office.Interop.Excel.ChartObjects
Dim myChart As Microsoft.Office.Interop.Excel.ChartObject
Dim chartRange As Microsoft.Office.Interop.Excel.Range

xlCharts = oSheet.ChartObjects
myChart = xlCharts.Add(10, 10, 600, 500)
chartPage = myChart.Chart
chartRange = oSheet.Range(oSheet.Cells(1, 1), oSheet.Cells(DArray.Length, MaxCols))
chartPage.SetSourceData(Source:=chartRange)
chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlLine
oExcel.DisplayAlerts = False
oBook.SaveAs(Path.Combine(MyDataPath, "MasterData.xlsx"))[/code]
<br/>


View the full article
 
Back
Top