none
Excel Graphs RRS feed

  • Question

  • Hey there,

     

    Yet another problem.....Maybe some of the same geniuses that have helped before can help with this one.

     

    Is it possible to display a graph from an excel sheet in a windows form?......

     

    Steve

    Tuesday, October 30, 2007 12:51 PM

Answers

  • you can use MicrosoftChart control - an activex control deployed by microsoft allows you to generate and display charts out of the data you upload...


    you can check out here to learn more about chart control and it usage..



    thanks
    Wednesday, October 31, 2007 9:25 AM

All replies

  • you can use MicrosoftChart control - an activex control deployed by microsoft allows you to generate and display charts out of the data you upload...


    you can check out here to learn more about chart control and it usage..



    thanks
    Wednesday, October 31, 2007 9:25 AM
  • Here is something that I used:

    Private Sub showGraphBtn_Click(sender As Object, e As EventArgs)
    	Dim filePath As String = "C:\Chart.xlsx"
    	Dim ef As ExcelFile = ExcelFile.Load(filePath, LoadOptions.XlsxDefault)
    
    	' Get first graph in first worksheet.
    	Dim chart As ExcelChart = ef.Worksheets(0).Charts(0)
    
    	Using stream As Stream = New MemoryStream()
    		' Format the graph and save it as image stream.
    		chart.Format(Me.pictureBox1.Width, Me.pictureBox1.Height, LengthUnit.Pixel)
    		       .Save(stream, SaveOptions.ImageDefault)
    
    		stream.Position = 0
    
    		' Display graph image on PictureBox control.
    		Me.pictureBox1.Image = Image.FromStream(stream)
    	End Using
    End Sub

    The code uses an API from an excel library for VB.NET. Additionally if interested here is how you can create an excel chart (graph) in VB.NET with it.

    Wednesday, January 13, 2016 9:07 AM