//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Range["A1:B8"].Value = new object[,] { {"Starting Amt", 130}, {"Measurement 1", 25}, {"Measurement 2", -75}, {"Subtotal", 80}, {"Measurement 3", 45}, {"Measurement 4", -65}, {"Measurement 5", 80}, {"Total", 140} }; worksheet.Range["A:A"].Columns.AutoFit(); // Create a waterfall chart. IShape shape = worksheet.Shapes.AddChart(ChartType.Waterfall, 300, 20, 300, 250); shape.Chart.SeriesCollection.Add(worksheet.Range["A1:B8"]); // Set subtotal&total points. IPoints points = shape.Chart.SeriesCollection[0].Points; points[3].IsTotal = true; points[7].IsTotal = true; // Connector lines are not shown. ISeries series = shape.Chart.SeriesCollection[0]; series.ShowConnectorLines = false; // Modify the fill color of the first legend entry. ILegendEntries legendEntries = shape.Chart.Legend.LegendEntries; legendEntries[0].Format.Fill.Color.ObjectThemeColor = ThemeColor.Accent6; // Save to an excel file workbook.Save("AddWaterfallChart.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.Range("A1:B8").Value = New Object(,) { {"Starting Amt", 130}, {"Measurement 1", 25}, {"Measurement 2", -75}, {"Subtotal", 80}, {"Measurement 3", 45}, {"Measurement 4", -65}, {"Measurement 5", 80}, {"Total", 140} } worksheet.Range("A:A").Columns.AutoFit() 'Create a waterfall chart. Dim shape As IShape = worksheet.Shapes.AddChart(ChartType.Waterfall, 300, 20, 300, 250) shape.Chart.SeriesCollection.Add(worksheet.Range("A1:B8")) 'Set subtotal&total points. Dim points As IPoints = shape.Chart.SeriesCollection(0).Points points(3).IsTotal = True points(7).IsTotal = True 'Connector lines are not shown. Dim series As ISeries = shape.Chart.SeriesCollection(0) series.ShowConnectorLines = False 'Modify the fill color of the first legend entry. Dim LegendEntries As ILegendEntries = shape.Chart.Legend.LegendEntries LegendEntries(0).Format.Fill.Color.ObjectThemeColor = ThemeColor.Accent6 ' save to an excel file workbook.Save("AddWaterfallChart.xlsx")