Export a chart from vb.net application to excel

Hello,
One of the requirements for the application that I am developing is for the user to be able to export charts such as graphs from the application to Excel.  I'm thinking it might be easer to just recreate the graph in Excel from the vb.net application via automation using the underlying datatables of the chart. I'd like to get feedback on that approach.  Thanks
Juan VelasquezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

-eVe-Commented:
Sure, that's the way! Check this sample:
http://www.codeproject.com/KB/office/Excel_Automation.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CodeCruiserCommented:
How about exporting the picture of the chart from VB.NET?
0
-eVe-Commented:
That's not really an export to Excel, is it? To Paint maybe ;-)
 
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

CodeCruiserCommented:
>That's not really an export to Excel, is it? To Paint maybe ;-)

Actually, my idea was to capture the app output of the chart into an image file and then add that image file to the Excel spreadsheet.
0
Juan VelasquezAuthor Commented:
Hello,
I've been thinking over both approaches and I think I will use both.  When a user wants to add a graph, the user click a button and the GraphDesigner form comes up.  The user then select the dataset and metrics to be graphed and the graph as well as the underlying dataset appears in the form.  If the user elects to add that graph, the user clicks okay and the user is then returned to the previous form where the graph will appear on the form (as image)  with the underlying datatable.  If the user want to print the results to excel, then the datatables are used to reconstruct the graph in the Excel worksheet and the dataset will appear below the graph.  I want to give  users to be able to interact with the graph when it is in Excel.  I could use the image on the form and use automation to create the graph for the excel sheet.  
Come to think of it, the graph in the preview pane is a charting control, why not just pass it as a cihart object to the form that displays the user selected charts.  I may be making things more complicated than they should be
0
CodeCruiserCommented:
Do you mean that you want to return the chart object to the calling form instead of an image?
0
Juan VelasquezAuthor Commented:
I'm still depating whether or not to return the chart object or an image would be best.  I think it really is a matter of how much if any interaction the user needs to have with the chart in the calling form.
0
CodeCruiserCommented:
That is the basic deciding factor. If you do decide to return a chart object, either return a cloned object or keep the other form in memory. Because if you return a reference to the chart(default) and dispose the form, chart would be disposed as well.
0
Juan VelasquezAuthor Commented:
I've just had a meeting with the client.  The user will not interact with the graph in the calling form, but will interact with it in the excel spreadsheet.  So given that, I will return the chart as a image to the calling form.  The calling form will also receive the underlying datatable.  I can then use automation to recreate the chart when the user elects to output the chart to excel.
0
Juan VelasquezAuthor Commented:
The code at http://www.codeproject.com/KB/office/Excel_Automation.aspx was what I was looking for.  I'm in the process of modifying it.  I also appreciate code cruisers advice on using an image.  I will implement both solutions as I mentioned earlier.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.