With this source code sample you may quickly learn how to add bar chart in VB.NET. What is ByteScout Spreadsheet SDK? It is the library (SDK) that is capable of writing, reading, modifying and calculating Excel and CSV spreadsheets. Most popular formulas can be calculated and reculculated with Excel installed. You may import or export data to and from CSV, XML, JSON as well as to and from databases, arrays. It can help you to add bar chart in your VB.NET application.
This code snippet below for ByteScout Spreadsheet SDK works best when you need to quickly add bar chart in your VB.NET application. Follow the instructions from the scratch to work and copy the VB.NET code. Implementing VB.NET application typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.
Our website provides trial version of ByteScout Spreadsheet SDK for free. It also includes documentation and source code samples.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
Imports Bytescout.Spreadsheet
Imports Bytescout.Spreadsheet.Charts
Imports System.IO
Module Module1
Sub Main()
' Create new Spreadsheet object
Dim spreadsheet As New Spreadsheet()
spreadsheet.RegistrationName = "demo"
spreadsheet.RegistrationKey = "demo"
' Add new worksheet
Dim sheet As Worksheet = spreadsheet.Workbook.Worksheets.Add("Sample")
' Add a random numbers
Dim length As Integer = 10
Dim rnd As New Random()
For i As Integer = 0 To length - 1
sheet.Cell(i, 0).Value = rnd.[Next](10)
sheet.Cell(i, 1).Value = rnd.[Next](10)
Next
' Add charts to worksheet
Dim barChart As Chart = sheet.Charts.AddChartAndFitInto(1, 3, 16, 9, ChartType.BarClustered)
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 0, length - 1, 0)))
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 1, length - 1, 1)))
barChart = sheet.Charts.AddChartAndFitInto(1, 10, 16, 16, ChartType.BarStacked)
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 0, length - 1, 0)))
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 1, length - 1, 1)))
barChart = sheet.Charts.AddChartAndFitInto(1, 17, 16, 23, ChartType.BarStacked100)
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 0, length - 1, 0)))
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 1, length - 1, 1)))
barChart = sheet.Charts.AddChartAndFitInto(17, 3, 32, 9, ChartType.BarClustered3D)
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 0, length - 1, 0)))
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 1, length - 1, 1)))
barChart = sheet.Charts.AddChartAndFitInto(17, 10, 32, 16, ChartType.BarStacked3D)
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 0, length - 1, 0)))
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 1, length - 1, 1)))
barChart = sheet.Charts.AddChartAndFitInto(17, 17, 32, 23, ChartType.BarStacked1003D)
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 0, length - 1, 0)))
barChart.SeriesCollection.Add(New Series(sheet.Range(0, 1, length - 1, 1)))
' Save it as XLS
spreadsheet.SaveAs("Output.xls")
' Close the document
spreadsheet.Close()
' Cleanup
spreadsheet.Dispose()
' Open generated XLS file in default associated application
Process.Start("Output.xls")
End Sub
End Module
60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page
Explore ByteScout Spreadsheet SDK Documentation
Explore Samples
Sign Up for ByteScout Spreadsheet SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Spreadsheet SDK Home Page
Explore ByteScout Spreadsheet SDK Documentation
Explore Samples
Sign Up for ByteScout Spreadsheet SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: