// 新規ワークブックの作成 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, 300, 10, 300, 300); worksheet.Range["A1:D6"].Value = new object[,] { {null, "系列1", "系列2", "系列3"}, {"項目1", 10, 25, 25}, {"項目2", -51, -36, 27}, {"項目3", 52, -85, -30}, {"項目4", 22, 65, 65}, {"項目5", 23, 69, 69} }; shape.Chart.HasTitle = true; shape.Chart.ChartTitle.Text = "作成したチャートのタイトル"; // チャートの作成 shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); // xlsx ファイルに保存 workbook.Save("CreateChart.xlsx");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 300, 10, 300, 300) worksheet.Range("A1:D6").Value = New Object(,) { {Nothing, "系列1", "系列2", "系列3"}, {"項目1", 10, 25, 25}, {"項目2", -51, -36, 27}, {"項目3", 52, -85, -30}, {"項目4", 22, 65, 65}, {"項目5", 23, 69, 69} } ' チャートの作成 shape.Chart.SeriesCollection.Add(worksheet.Range("A1:D6"), RowCol.Columns, True, True) ' xlsx ファイルに保存 workbook.Save("CreateChart.xlsx")