//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A2:A6"].NumberFormat = "m/d/yyyy"; worksheet.Range["A1:D6"].Value = new object[,] { {null, "S1", "S2", "S3"}, {new DateTime(2015, 10, 7), 10, 25, 25}, {new DateTime(2015, 10, 24), 51, 36, 27}, {new DateTime(2015, 11, 8), 52, 85, 30}, {new DateTime(2015, 11, 25), 22, 65, 65}, {new DateTime(2015, 12, 10), 23, 69, 69} }; worksheet.Columns[0].AutoFit(); GrapeCity.Documents.Excel.Drawing.IShape shape = worksheet.Shapes.AddChart(GrapeCity.Documents.Excel.Drawing.ChartType.ColumnClustered, 250, 20, 360, 230); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); GrapeCity.Documents.Excel.Drawing.IAxis category_axis = shape.Chart.Axes.Item(GrapeCity.Documents.Excel.Drawing.AxisType.Category); category_axis.MaximumScale = new DateTime(2015, 12, 20).ToOADate(); category_axis.MinimumScale = new DateTime(2015, 10, 1).ToOADate(); category_axis.BaseUnit = GrapeCity.Documents.Excel.Drawing.TimeUnit.Months; category_axis.MajorUnitScale = GrapeCity.Documents.Excel.Drawing.TimeUnit.Months; category_axis.MajorUnit = 1; category_axis.MinorUnitScale = GrapeCity.Documents.Excel.Drawing.TimeUnit.Days; category_axis.MinorUnit = 15; // Save to an excel file workbook.Save("ConfigCategoryAxisUnits.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("A2:A6").NumberFormat = "m/d/yyyy" worksheet.Range("A1:D6").Value = New Object(,) { {Nothing, "S1", "S2", "S3"}, { #10/7/2015#, 10, 25, 25 }, { #10/24/2015#, 51, 36, 27 }, { #11/8/2015#, 52, 85, 30 }, { #11/25/2015#, 22, 65, 65 }, { #12/10/2015#, 23, 69, 69 } } worksheet.Columns(0).AutoFit() Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 250, 20, 360, 230) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:D6"), RowCol.Columns, True, True) Dim category_axis As IAxis = shape.Chart.Axes.Item(AxisType.Category) category_axis.MaximumScale = (#12/20/2015#).ToOADate() category_axis.MinimumScale = (#10/1/2015#).ToOADate() category_axis.BaseUnit = TimeUnit.Months category_axis.MajorUnitScale = TimeUnit.Months category_axis.MajorUnit = 1 category_axis.MinorUnitScale = TimeUnit.Days category_axis.MinorUnit = 15 ' save to an excel file workbook.Save("ConfigCategoryAxisUnits.xlsx")