DataGridView to Excel File

Export data from a DataGridView to Excel File

Page 1 of 1

2 Replies - 11459 Views - Last Post: 21 August 2010 - 03:48 PM Rate Topic: ***-- 2 Votes

#1 programmer4life  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 25-February 10

DataGridView to Excel File

Posted 21 August 2010 - 02:03 PM

Hey,

So I'm working on this project. I got around 60 images or so which I need to OCR, then I'll be inputting that data into my program which formats it and inputs it within this DataGridView. Now, I need the same data to be exported into an excel file. I saw several tutorials online but none of them are current (for VB 2008 or 2010). Either that, or they're not for VB.NET Windows Form Application. [I'm using VS 2010] :helpsmilie:

I'm fairly new to Datagridview as well. Just learnt how to add data to datagridview using this tutorial:
http://vb.net-inform...ridview_add.htm

I was hoping you could help me out with where to start once I get my data all set up in the datagridview?

thanks :bigsmile:

Is This A Good Question/Topic? 0
  • +

Replies To: DataGridView to Excel File

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1046
  • View blog
  • Posts: 4,072
  • Joined: 02-July 08

Re: DataGridView to Excel File

Posted 21 August 2010 - 03:28 PM

Couple of options;
1) iterate thru the rows and comma separate them and save as .csv - excel opens these very well,
2) use excel automation - many tutorials on line for that.
Was This Post Helpful? 1
  • +
  • -

#3 programmer4life  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 25-February 10

Re: DataGridView to Excel File

Posted 21 August 2010 - 03:48 PM

View Posthawkvalley1, on 21 August 2010 - 02:28 PM, said:

Couple of options;
1) iterate thru the rows and comma separate them and save as .csv - excel opens these very well,
2) use excel automation - many tutorials on line for that.


Yeah, I found a tutorial and it worked:
http://www.java-samp...tutorialid=1054

I'm guessing that one is excel automation? Oh, and I was checking online tutorials and every one kept saying add reference 'Microsoft Office Library 12'(for Office 2007) but that didn't work for some reason in VS 2010. So I looked around and found out you gotta add reference for 'Microsoft Excel 12.0 Object Library' and I finally got this line in the code to work:

Imports Excel = Microsoft.Office.Interop.Excel

Btw, thx for the help :clap:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1