Serving the Quantitative Finance Community

 
User avatar
terrorbyte
Topic Author
Posts: 3
Joined: July 14th, 2002, 3:00 am

Reading Excel 2000 with VB.Net

October 21st, 2004, 5:20 pm

Does anyone have a code snippet that will show me how they read data from Excel using VB.Net?I have done this successfully with VB6 using the "Worksheets" and "Cells" object. I am trying to read in about 9000 rows, each with about 10 fields. Nothing tricky. Just a sequential read until I hit a blank cell.However, with VB.Net and Option Strict On, the process is forcing me to use the "Range" object which seems to be a lot slower. Something that took about 20secs in VB6 is now taking about 50 secs in .Net. I am about to give up, save the data to a CSV on the sly and read it in from there (which will be faster than the original 20secs but a little sloppy).Note that I have done all the normal periphal stuff like turning off Screenupdating, Calculation, UpdateLinks yada yada.Any help would be appreciated.RegardsTerror
 
User avatar
terrorbyte
Topic Author
Posts: 3
Joined: July 14th, 2002, 3:00 am

Reading Excel 2000 with VB.Net

October 21st, 2004, 5:47 pm

Cancel this request.I am going to use ADO, which means all the grinding will happen internally in Excel and no iterating will be required.
 
User avatar
terrorbyte
Topic Author
Posts: 3
Joined: July 14th, 2002, 3:00 am

Reading Excel 2000 with VB.Net

October 21st, 2004, 7:38 pm

I am talking to myself here but I thought I would let you know the results.Using ADO, the 9000 records with 10 fields come out in 3 seconds. ADO is a winner!
 
User avatar
magriggs
Posts: 0
Joined: October 19th, 2004, 9:23 pm

Reading Excel 2000 with VB.Net

October 21st, 2004, 7:45 pm

You should get your data into a proper database anyway, rather than sucking it out of Excel. MSDE is a free version of SQL Server 2000, with virtually all of the functionality. mike
 
User avatar
Russell
Posts: 1
Joined: October 16th, 2001, 5:18 pm

Reading Excel 2000 with VB.Net

October 22nd, 2004, 10:29 am

btw the time consuming bit will be making each call across boundary i.e. Vb.net to excelIf insted of getting a cell at a time, you get say the values of 1000 or 10000 cells it will be much quicker. You're making one slow call (prob a couple of seconds) instead of a lot (9000ish) of calls.
 
User avatar
terrorbyte
Topic Author
Posts: 3
Joined: July 14th, 2002, 3:00 am

Reading Excel 2000 with VB.Net

October 22nd, 2004, 12:33 pm

magriggs, the corporate SQL Server is the destination for all this stuff! Excel is just a good mechanism to build all the data before pounding it onto the server.