Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 8th, 2005, 05:36 AM
Registered User
 
Join Date: Feb 2005
Location: hyderabad, AP, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sreeramulu
Default Unable to open excel file thru vb.net

Hi,
    I want to open an existing excel file thru vb.net programmatically. Let me know how to do it.

Sreeramulu
Reply With Quote
  #2 (permalink)  
Old January 29th, 2008, 09:09 AM
Registered User
 
Join Date: Dec 2005
Location: Hyderabad, Andhra Pradesh, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to caveatashish Send a message via Yahoo to caveatashish
Default

Hi,

Just share the answer with me if you get the reply

Reply With Quote
  #3 (permalink)  
Old June 1st, 2008, 05:14 AM
Authorized User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet

        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Open("c:\test1.xlsx")
        xlWorkSheet = xlWorkBook.Worksheets("sheet1")

full src

http://vb.net-informations.com/excel..._open_file.htm



Reply With Quote
  #4 (permalink)  
Old June 1st, 2008, 12:26 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii sreeramulu!!

Put post in proper forum..
,you may get early response than waiting for long time,its just a suggestion...



Cheers :)

vinod
Reply With Quote
  #5 (permalink)  
Old June 2nd, 2010, 01:02 AM
Registered User
 
Join Date: Dec 2005
Location: Hyderabad, Andhra Pradesh, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to caveatashish Send a message via Yahoo to caveatashish
Default Close the file

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet

xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Open("c:\test1.xlsx")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")


once you are done with the excel file don't forget to close the file, otherwise it will give an error if you try to open that excel file again either through code or manually

xlApp.Workbooks.Close
Reply With Quote
  #6 (permalink)  
Old December 6th, 2013, 04:19 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Unable to open excel file thru vb.net

Hi, just to add to a caveatashish's answer, when you are finished with your spreadsheet’s tasks it is not enough to close the file. You need to release every COM object which was created and quit the application, you can read more about this on this discussion:
Code:
xlApp.Quit()
Marshal.ReleaseComObject(xlWorkSheet)
Marshal.ReleaseComObject(xlWorkBook)
Marshal.ReleaseComObject(xlApp)
xlApp = Nothing
Also you can try this simpler approach with a help of this VB.NET library, it has an easy to use API for reading an excel file in .NET and you will not have to bother with releasing the COM objects from the memory.
Code:
Dim xlWorkBook As ExcelFile = ExcelFile.Load("c:\test1.xlsx")
Dim xlWorkSheet As ExcelWorksheet = xlWorkBook.Worksheets("sheet1")
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Unable to open include file. Allen_T 08 C++ Programming 4 July 7th, 2016 01:43 PM
Read an already open Excel file in VB.NET sunilr General .NET 4 February 28th, 2014 07:20 AM
Unable to open Excel with macro guptasourav ASP.NET 1.x and 2.0 Application Design 0 January 18th, 2007 01:52 AM
Unable to open script file Pickle Dreamweaver (all versions) 1 October 31st, 2005 02:35 PM
unable to open flv file sentme_mail Flash (all versions) 0 December 27th, 2004 06:50 AM



All times are GMT -4. The time now is 02:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.