//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; // Add columnClustered chart GrapeCity.Documents.Excel.Drawing.IShape shape = worksheet.Shapes.AddChart(GrapeCity.Documents.Excel.Drawing.ChartType.ColumnClustered, 250, 20, 360, 230); // Set data for the chart worksheet.Range["A1:D6"].Value = new object[,] { {null, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -51, 36, 27}, {"Item3", 52, 50, -30}, {"Item4", 22, 65, 30}, {"Item5", 23, 40, 69} }; // Set series data shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); // Set plot area's format GrapeCity.Documents.Excel.Drawing.IPlotArea plotarea = shape.Chart.PlotArea; plotarea.Format.Fill.Color.RGB = Color.LightGray; plotarea.Format.Line.Color.RGB = Color.Gray; plotarea.Format.Line.Weight = 1; // Save to an excel file workbook.Save("ConfigPlotAreaFormat.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) ' add columnClustered chart Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 250, 20, 360, 230) ' set data for the chart worksheet.Range("A1:D6").Value = New Object(,) { {Nothing, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -51, 36, 27}, {"Item3", 52, 50, -30}, {"Item4", 22, 65, 30}, {"Item5", 23, 40, 69} } ' set series data shape.Chart.SeriesCollection.Add(worksheet.Range("A1:D6"), RowCol.Columns, True, True) ' set plot area's format Dim plotarea As IPlotArea = shape.Chart.PlotArea plotarea.Format.Fill.Color.RGB = Color.LightGray plotarea.Format.Line.Color.RGB = Color.Gray plotarea.Format.Line.Weight = 1 ' save to an excel file workbook.Save("ConfigPlotAreaFormat.xlsx")