//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:B11"].Value = new object[,] { {"Complaint", "Count"}, {"Too noisy", 27}, {"Overpriced", 789}, {"Food is tasteless", 65}, {"Food is not fresh", 9}, {"Food is too salty", 15}, {"Not clean", 30}, {"Unfriendly staff", 12}, {"Wait time", 109}, { "No atmosphere", 45}, {"Small portions", 621 } }; worksheet.Range["A:A"].Columns.AutoFit(); // Create a pareto chart. IShape shape = worksheet.Shapes.AddChart(ChartType.Pareto, 300, 20, 300, 200); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B11"]); // Set bins type by size. shape.Chart.ChartGroups[0].BinsType = BinsType.BinsTypeBinSize; shape.Chart.ChartGroups[0].BinWidthValue = 300; // Set underflow bin value. shape.Chart.ChartGroups[0].BinsUnderflowEnabled = true; shape.Chart.ChartGroups[0].BinsUnderflowValue = 50; // Save to an excel file workbook.Save("AddParetoChart.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("A1:B11").Value = New Object(,) { {"Complaint", "Count"}, {"Too noisy", 27}, {"Overpriced", 789}, {"Food is tasteless", 65}, {"Food is not fresh", 9}, {"Food is too salty", 15}, {"Not clean", 30}, {"Unfriendly staff", 12}, {"Wait time", 109}, {"No atmosphere", 45}, {"Small portions", 621} } worksheet.Range("A:A").Columns.AutoFit() 'Create a pareto chart. Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.Pareto, 300, 20, 300, 200) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:B11")) With shape.Chart.ChartGroups(0) 'Set bins type by size. .BinsType = BinsType.BinsTypeBinSize .BinWidthValue = 300 'Set underflow bin value. .BinsUnderflowEnabled = True .BinsUnderflowValue = 50 End With ' save to an excel file workbook.Save("AddParetoChart.xlsx")