// 新規ワークブックの作成 var workbook = new GrapeCity.Documents.Excel.Workbook(); var worksheet = workbook.ActiveSheet; var data = new object[,] { { null , "2017", "2018", "2019", "2020", "2021", "2022", "2023" }, { "携帯電話",0.9,0.13,0.15,0.18,0.17,0.18,0.04 }, { "タブレット", 0.05, 0.08, 0.12, 0.13, 0.15, 0.17, 0.54 }, { "家庭用品",0.43,0.35,0.23,0.13,0.13,0.15,0.16 }, { "車",0.51,0.55,0.45,0.55,0.08,0.45,0.46 }, { "食料品",0.51,0.55,0.25,0.77,0.05,0.45,0.56 }, { "医療品",0.35,0.2,1,0.23,0.33,0.5,1 }, }; worksheet.Range["A1:H7"].Value = data; // スタイルを設定 worksheet.Range["A1:H7"].Style.HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["A1:A7"].ColumnWidth = 18; // チャートを作成 GrapeCity.Documents.Excel.Drawing.IShape shape = worksheet.Shapes.AddChart(GrapeCity.Documents.Excel.Drawing.ChartType.Line, 10, 150, 400, 200); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:H7"], GrapeCity.Documents.Excel.Drawing.RowCol.Columns, true, true); shape.Chart.ChartTitle.Text = "製品販売"; // 線が平滑線になるよう設定 foreach (var item in shape.Chart.SeriesCollection) { item.Smooth = true; } // PDF ファイルに保存 workbook.Save("SmoothLineChartPdf.pdf");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim worksheet = workbook.ActiveSheet Dim data = New Object(,) { {Nothing, "2017", "2018", "2019", "2020", "2021", "2022", "2023"}, {"携帯電話", 0.9, 0.13, 0.15, 0.18, 0.17, 0.18, 0.04}, {"タブレット", 0.05, 0.08, 0.12, 0.13, 0.15, 0.17, 0.54}, {"家庭用品", 0.43, 0.35, 0.23, 0.13, 0.13, 0.15, 0.16}, {"車", 0.51, 0.55, 0.45, 0.55, 0.08, 0.45, 0.46}, {"食料品", 0.51, 0.55, 0.25, 0.77, 0.05, 0.45, 0.56}, {"医療品", 0.35, 0.2, 1, 0.23, 0.33, 0.5, 1} } worksheet.Range("A1:H7").Value = data ' スタイルを設定 worksheet.Range("A1:H7").Style.HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("A1:A7").ColumnWidth = 18 ' チャートを作成 Dim shape As GrapeCity.Documents.Excel.Drawing.IShape = worksheet.Shapes.AddChart(GrapeCity.Documents.Excel.Drawing.ChartType.Line, 10, 150, 400, 200) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:H7"), GrapeCity.Documents.Excel.Drawing.RowCol.Columns, True, True) shape.Chart.ChartTitle.Text = "製品販売" ' 線が平滑線になるよう設定 For Each item In shape.Chart.SeriesCollection item.Smooth = True Next item ' PDF ファイルに保存 workbook.Save("SmoothLineChartPdf.pdf")