// 新規ワークブックの作成 var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; // 範囲["G1:M21"]のデータでチャートを作成 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.SeriesCollection.Add(worksheet.Range["A1:D6"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); shape.Chart.HasTitle = false; // 切り取る範囲はチャートを描画した範囲を含む必要があります worksheet.Range["F1:L21"].Cut(worksheet.Range["N1"]); //worksheet.Range["F1:L21"].Cut(worksheet.Range["N1:T21"]); // シートをまたいでチャートを切り取る方法 // IWorksheet worksheet2 = workbook.Worksheets.Add() // worksheet.Range["F1:L21"].Cut(worksheet2.Range["E1"]); // worksheet.Range["F1:L21"].Cut(worksheet2.Range["N1:T21"]); // xlsx ファイルに保存 workbook.Save("ChartCut.xlsx");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) ' 範囲["G1:M21"]のデータでチャートを作成 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) ' 切り取る範囲はチャートを描画した範囲を含む必要があります worksheet.Range("F1:L21").Cut(worksheet.Range!N1) ' worksheet.Range("F1:L21").Cut(worksheet.Range("N1:T21")) ' シートをまたいでチャートを切り取る方法 ' Dim worksheet2 = workbook.Worksheets.Add() ' worksheet.Range("F1:L21").Cut(worksheet2.Range!E1) ' worksheet.Range("F1:L21").Cut(worksheet2.Range("N1:T21")) ' xlsx ファイルに保存 workbook.Save("ChartCut.xlsx")