//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:D6"].Value = new object[,] { {null, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -20, 36, 27}, {"Item3", 52, 70, 30}, {"Item4", 22, 33, -20}, {"Item5", 23, 30, 30} }; shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); shape.Chart.HasLegend = true; GrapeCity.Documents.Excel.Drawing.ILegend legend = shape.Chart.Legend; // Position. legend.Position = GrapeCity.Documents.Excel.Drawing.LegendPosition.Left; // Font. legend.Font.Color.RGB = Color.Red; legend.Font.Italic = true; // Save to an excel file workbook.Save("ConfigLegendPositionAndLayout.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:D6").Value = New Object(,) { {Nothing, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -20, 36, 27}, {"Item3", 52, 70, 30}, {"Item4", 22, 33, -20}, {"Item5", 23, 30, 30} } shape.Chart.SeriesCollection.Add(worksheet.Range("A1:D6"), RowCol.Columns, True, True) shape.Chart.HasLegend = True Dim legend As ILegend = shape.Chart.Legend 'position. legend.Position = LegendPosition.Left 'font. legend.Font.Color.RGB = Color.Red legend.Font.Italic = True ' save to an excel file workbook.Save("ConfigLegendPositionAndLayout.xlsx")