Wanting to format excel chart axis dates
-
Wednesday, August 22, 2012 8:45 PM
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. I'd 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:
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"))
All Replies
-
Thursday, August 23, 2012 12:03 AM
I finally found a way, I set the sheet dates to format "[$-409]mmm-yy;@"
- Marked As Answer by Devon_Nullman Thursday, August 23, 2012 12:03 AM

