//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; GrapeCity.Documents.Excel.Drawing.IShape shape = worksheet.Shapes.AddChart(GrapeCity.Documents.Excel.Drawing.ChartType.ColumnClustered, 250, 20, 360, 230); worksheet.Range["A1:B5"].Value = new object[,] { {null, "S1","S2"}, {"Item1", -20,10}, {"Item2", 30,60}, {"Item3", 50 ,80}, {"Item3", 40,70 } }; shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B5"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); GrapeCity.Documents.Excel.Drawing.ISeries series1 = shape.Chart.SeriesCollection[0]; series1.HasDataLabels = true; // Customize data labels' text. series1.DataLabels.ShowCategoryName = true; series1.DataLabels.ShowSeriesName = true; series1.DataLabels.ShowLegendKey = true; // Save to an excel file workbook.Save("ConfigDataLabelText.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 250, 20, 360, 230) worksheet.Range("A1:B5").Value = New Object(,) { {Nothing, "S1", "S2"}, {"Item1", -20, 10}, {"Item2", 30, 60}, {"Item3", 50, 80}, {"Item3", 40, 70} } shape.Chart.SeriesCollection.Add(worksheet.Range("A1:B5"), RowCol.Columns, True, True) Dim series1 As ISeries = shape.Chart.SeriesCollection(0) series1.HasDataLabels = True 'customize data lables' text. series1.DataLabels.ShowCategoryName = True series1.DataLabels.ShowSeriesName = True series1.DataLabels.ShowLegendKey = True ' save to an excel file workbook.Save("ConfigDataLabelText.xlsx")