//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); var worksheet = workbook.ActiveSheet; var data = new object[,] { { null , "2017", "2018", "2019", "2020", "2021", "2022", "2023" }, { "Mobile Phones",0.9,0.13,0.15,0.18,0.17,0.18,0.04 }, { "Tablets", 0.05, 0.08, 0.12, 0.13, 0.15, 0.17, 0.54 }, { "Household items",0.43,0.35,0.23,0.13,0.13,0.15,0.16 }, { "Vehicles",0.51,0.55,0.45,0.55,0.08,0.45,0.46 }, { "Groceries",0.51,0.55,0.25,0.77,0.05,0.45,0.56 }, { "Personal care",0.35,0.2,1,0.23,0.33,0.5,1 }, }; worksheet.Range["A1:H7"].Value = data; // set style worksheet.Range["A1:H7"].Style.HorizontalAlignment = HorizontalAlignment.Center; worksheet.Range["A1:A7"].ColumnWidth = 18; // create chart 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 = "Product Sales"; // set line curve smoothing setting foreach (var item in shape.Chart.SeriesCollection) { item.Smooth = true; } // Save to a pdf file workbook.Save("SmoothLineChartPdf.pdf");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet = workbook.ActiveSheet Dim data = New Object(,) { {Nothing, "2017", "2018", "2019", "2020", "2021", "2022", "2023"}, {"Mobile Phones", 0.9, 0.13, 0.15, 0.18, 0.17, 0.18, 0.04}, {"Tablets", 0.05, 0.08, 0.12, 0.13, 0.15, 0.17, 0.54}, {"Household items", 0.43, 0.35, 0.23, 0.13, 0.13, 0.15, 0.16}, {"Vehicles", 0.51, 0.55, 0.45, 0.55, 0.08, 0.45, 0.46}, {"Groceries", 0.51, 0.55, 0.25, 0.77, 0.05, 0.45, 0.56}, {"Personal care", 0.35, 0.2, 1, 0.23, 0.33, 0.5, 1} } worksheet.Range("A1:H7").Value = data ' set style worksheet.Range("A1:H7").Style.HorizontalAlignment = HorizontalAlignment.Center worksheet.Range("A1:A7").ColumnWidth = 18 ' create chart 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 = "Product Sales" ' set line curve smoothing setting For Each item In shape.Chart.SeriesCollection item.Smooth = True Next item ' save to a pdf file workbook.Save("SmoothLineChartPdf.pdf")