views:

248

answers:

5

Hi,

I am generating report in excel sheet(which is coming from Microsoft Access).
For 100 records, it can generate the excel sheet in 2 to 3 seconds. But, it takes 10 minutes for more than 2000 records.

Is there a solution or is there any other way to generate report in excel sheet?

+7  A: 

Use Excel's CopyFromRecordset. Much faster than cell by cell. Modules: Transferring Records to Excel with Automation

Also see Excel automation formatting examples for some additional tips in working with Excel.

Tony Toews
A: 

If Tony's answer won't work for you ... you might have to "profile" your application. I do not know of any tools that will do it for you (such as you have in .net) but you can always sprinkle your output code with "debug.print now() & " to see where your bottleneck is.

Seth

Seth Spearman
I've watched the code myself. The bottleneck is in the tight loop updating the cells one by one. It gets painfully slow with any volume of data. Whereas CopyFromRecordset is exceedingly fast.
Tony Toews
A: 

SpreadsheetGear for .NET is much faster than using Excel from VB.NET as demonstrated by customer comments on this page.

You can see live samples here and download a free trial here.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson
I'm not sure how a VB.Net product would work in Access?
Tony Toews
My bad - when I read the question I got the apparently incorrect impression that it was a VB.NET application generating an Excel workbook by connecting to an access db...
Joe Erickson
+1  A: 

If I'm understanding your problem, this is a very easy fix that doesn't require coding.

  1. Open up Excel
  2. Go to Data->"Import External Data"->"Import Data"
  3. Choose your Access file and table/query of choice.
  4. Whenever you want to refresh the data, just right click on the import area and click refresh.

Later, you can code up some VBA to auto-refresh and save the XL for you.

PowerUser