User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 361,856 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,514 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 1296 | Replies: 5
Reply
Join Date: Dec 2007
Posts: 9
Reputation: mpatram is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mpatram mpatram is offline Offline
Newbie Poster

Solution how to link an excel program in vb.net?

  #1  
Dec 3rd, 2007
Hi All,

I've some excel programs. I want to attach those programs to my vb.net application. Is it possible? If yes then How? If its possible then can the excel file be editable?
M Patra
SSE
AISL, India
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: High Point, NC
Posts: 37
Reputation: emurf is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
emurf emurf is offline Offline
Light Poster

Re: how to link an excel program in vb.net?

  #2  
Dec 3rd, 2007
The first thing that you'll need to do is add a reference to the Microsoft Excel Object Library. In your code you will need to create an Excel application object and excel workbooks. Then you should be able to access the file to edit the cells. It may look something like this;
'declare an instance of an excel application
Dim oExcel As New Microsoft.Office.Interop.Excel.Application

'make a book 
Dim oBook As Microsoft.Office.Interop.Excel.Workbook
'set it to the excel doc
oBook = oExcel.Workbooks.Open("path to your file")

'get the sheet 
Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet = oBook.Worksheets("Sheetname")

'here you would put any other code to edit the sheet

There is information about manipulating the data at this link, http://support.microsoft.com/default...b;EN-US;302094
Reply With Quote  
Join Date: Dec 2007
Posts: 1
Reputation: 隐姓埋名 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
隐姓埋名 隐姓埋名 is offline Offline
Newbie Poster

Re: how to link an excel program in vb.net?

  #3  
Dec 27th, 2007
I wonder how to process the data in the excel cells with the vb.net codes. thnx
Reply With Quote  
Join Date: Nov 2007
Location: High Point, NC
Posts: 37
Reputation: emurf is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
emurf emurf is offline Offline
Light Poster

Re: how to link an excel program in vb.net?

  #4  
Dec 31st, 2007
If you are wanting to just read what is on the sheet like it is a database column you would use an OleDb connection object like this;
Dim strSql As String = "select * from [" & SheetName & "$]"
Dim conConn As New OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & c:\PathToFile & "; " & _
"Extended Properties=Excel 8.0;")
Dim cmd As New OleDb.OleDbCommand(strSql, conConn)
Dim dr As OleDb.OleDbDataReader

Then use as any other OleDb connection. To access individual cells you need to create Excel objects like the post above and then loop through each row and cell, check the link in that post for examples.
Last edited by emurf : Dec 31st, 2007 at 11:49 am.
Reply With Quote  
Join Date: Aug 2005
Location: Trailer trash caravan park, just down the road from loserville
Posts: 4,549
Reputation: iamthwee is a jewel in the rough iamthwee is a jewel in the rough iamthwee is a jewel in the rough iamthwee is a jewel in the rough 
Rep Power: 15
Solved Threads: 284
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: how to link an excel program in vb.net?

  #5  
Jan 1st, 2008
A word of warning I found out later if using oledb - the spreadsheet must be perfect

In other words:

Every column must either number numeric or non-numeric, if there is a mismatch it doesn't work.
Last edited by iamthwee : Jan 1st, 2008 at 3:03 pm.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Feb 2008
Posts: 5
Reputation: rps_x is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rps_x rps_x is offline Offline
Newbie Poster

Re: how to link an excel program in vb.net?

  #6  
Mar 23rd, 2008
Originally Posted by mpatram View Post
Hi All,

I've some excel programs. I want to attach those programs to my vb.net application. Is it possible? If yes then How? If its possible then can the excel file be editable?



plz check this

http://vb.net-informations.com/excel..._tutorials.htm
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 5:51 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC