Excel Chart Export as Picture file VB.NET

In order to enhance the versatility and accessibility of our created charts in Excel, it is valuable to understand how to export them as picture files, such as BMP, JPG, GIF, and more. The following program presents a solution for exporting a chart from Excel to a picture file format.

Before proceeding with the export process, it is essential to populate the Excel sheet with the relevant data, ensuring that it is structured and organized appropriately. This step serves as the foundation for chart creation and lays the groundwork for accurate and meaningful visual representations.

Once the data has been entered and the Excel sheet takes shape, we can proceed to create a chart object in VB.NET. By using the capabilities of VB.NET, we have the ability to dynamically configure the chart object according to our specific needs. This involves defining essential attributes such as positions, size, data range, chart type, and more, allowing us to tailor the chart precisely to our desired specifications.


After successfully configuring the chart object, we can now explore the process of exporting it as a picture file. Utilizing VB.NET's command for exporting the chart, we can save it in various popular image formats, including BMP, JPG, GIF, and others. This export functionality provides flexibility and convenience, enabling us to utilize the chart in various contexts outside of the Excel environment.

By exporting the chart as a picture file, we unlock the potential to incorporate it into different documents, presentations, reports, or even webpages, thus extending its reach and impact beyond the confines of Excel. This capability allows for seamless integration of the chart into diverse mediums, enhancing its visibility and accessibility to a wider audience.

The following picture shows the BMP file export from Excel.


The ability to export charts as picture files broadens the scope of their application, enabling effective communication and data dissemination. It facilitates the sharing of valuable insights and visually compelling representations with stakeholders, colleagues, or clients, regardless of their familiarity or access to Excel.

Full Source VB.NET
Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Dim misValue As Object = System.Reflection.Missing.Value xlApp = New Excel.ApplicationClass xlWorkBook = xlApp.Workbooks.Add(misValue) xlWorkSheet = xlWorkBook.Sheets("sheet1") 'add data xlWorkSheet.Cells(1, 1) = "" xlWorkSheet.Cells(1, 2) = "Student1" xlWorkSheet.Cells(1, 3) = "Student2" xlWorkSheet.Cells(1, 4) = "Student3" xlWorkSheet.Cells(2, 1) = "Term1" xlWorkSheet.Cells(2, 2) = "80" xlWorkSheet.Cells(2, 3) = "65" xlWorkSheet.Cells(2, 4) = "45" xlWorkSheet.Cells(3, 1) = "Term2" xlWorkSheet.Cells(3, 2) = "78" xlWorkSheet.Cells(3, 3) = "72" xlWorkSheet.Cells(3, 4) = "60" xlWorkSheet.Cells(4, 1) = "Term3" xlWorkSheet.Cells(4, 2) = "82" xlWorkSheet.Cells(4, 3) = "80" xlWorkSheet.Cells(4, 4) = "65" xlWorkSheet.Cells(5, 1) = "Term4" xlWorkSheet.Cells(5, 2) = "75" xlWorkSheet.Cells(5, 3) = "82" xlWorkSheet.Cells(5, 4) = "68" 'create chart Dim chartPage As Excel.Chart Dim xlCharts As Excel.ChartObjects Dim myChart As Excel.ChartObject Dim chartRange As Excel.Range xlCharts = xlWorkSheet.ChartObjects myChart = xlCharts.Add(10, 80, 300, 250) chartPage = myChart.Chart chartRange = xlWorkSheet.Range("A1", "d5") chartPage.SetSourceData(Source:=chartRange) chartPage.ChartType = Excel.XlChartType.xlColumnClustered 'exporting chart as picture file xlWorkSheet.ChartObjects(1).chart.Export(FileName:= _ "C:\excel_chart_export.bmp", FilterName:="BMP") xlWorkSheet.SaveAs("C:\vbexcel.xlsx") xlWorkBook.Close() xlApp.Quit() releaseObject(xlApp) releaseObject(xlWorkBook) releaseObject(xlWorkSheet) MsgBox("Chart File Exported !") End Sub Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub End Class


By following the above steps and using the power of VB.NET, we can unlock the potential of Excel's charting capabilities and seamlessly export them as picture files. This empowers us to utilize the full potential of our charts and use them in various contexts, thereby enhancing data communication and decision-making processes.