//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 histogram chart. IShape shape = worksheet.Shapes.AddChart(ChartType.Histogram, 300, 20, 300, 200); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B11"]); //Sets bins type by count. shape.Chart.ChartGroups[0].BinsType = BinsType.BinsTypeBinCount; shape.Chart.ChartGroups[0].BinsCountValue = 3; //Set overflow bin value shape.Chart.ChartGroups[0].BinsOverflowEnabled = true; shape.Chart.ChartGroups[0].BinsOverflowValue = 500; // Save to an excel file workbook.Save("AddHistogramChart.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 histogram chart. Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.Histogram, 300, 20, 300, 200) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:B11")) With shape.Chart.ChartGroups(0) 'Sets bins type by count. .BinsType = BinsType.BinsTypeBinCount .BinsCountValue = 3 'Set overflow bin value .BinsOverflowEnabled = True .BinsOverflowValue = 500 End With ' save to an excel file workbook.Save("AddHistogramChart.xlsx")