473,378 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Export data to excel too slow

I can export the data to excel, but it is really really slow. need 5-6 mins
to export 30 fields (a hundred records) . for my old vfp application, less
than 3 minutes. for 500-800 records.
Does any idea to improve the alog ?? Or what Can I do in my sql server ?
Thanks a lot

'For displaying the column name in the the excel file.
For intColumn = 0 To dsExcelExport.Tables(0).Columns.Count - 1
.Cells(1, intColumn + 1).Value =
dsExcelExport.Tables(0).Columns(intColumn).ColumnN ame.ToString
Next
'For displaying the column value row-by-row in the the excel
file.
For intRow = 0 To dsExcelExport.Tables(0).Rows.Count - 1
For intColumnValue = 0 To
dsExcelExport.Tables(0).Columns.Count - 1
.Cells(intRow + 1, intColumnValue + 1).Value =
dsExcelExport.Tables(0).Rows(intRow).ItemArray(int ColumnValue).ToString
Next
Next
Nov 21 '05 #1
4 4604
Hi,

I prefer to create an xml spread sheet and transform it to an xls.
Here is an example of how to do it. The sample is for asp.net app but the
method will work with a windows forms app.

http://support.microsoft.com/default...b;en-us;319180

Ken
--------------------
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
I can export the data to excel, but it is really really slow. need 5-6 mins
to export 30 fields (a hundred records) . for my old vfp application, less
than 3 minutes. for 500-800 records.
Does any idea to improve the alog ?? Or what Can I do in my sql server ?
Thanks a lot

'For displaying the column name in the the excel file.
For intColumn = 0 To dsExcelExport.Tables(0).Columns.Count - 1
.Cells(1, intColumn + 1).Value =
dsExcelExport.Tables(0).Columns(intColumn).ColumnN ame.ToString
Next
'For displaying the column value row-by-row in the the excel
file.
For intRow = 0 To dsExcelExport.Tables(0).Rows.Count - 1
For intColumnValue = 0 To
dsExcelExport.Tables(0).Columns.Count - 1
.Cells(intRow + 1, intColumnValue + 1).Value =
dsExcelExport.Tables(0).Rows(intRow).ItemArray(int ColumnValue).ToString
Next
Next

Nov 21 '05 #2
On Tue, 25 Oct 2005 18:15:54 +0800, "Agnes" <ag***@dynamictech.com.hk> wrote:

¤ I can export the data to excel, but it is really really slow. need 5-6 mins
¤ to export 30 fields (a hundred records) . for my old vfp application, less
¤ than 3 minutes. for 500-800 records.
¤ Does any idea to improve the alog ?? Or what Can I do in my sql server ?
¤ Thanks a lot
¤
¤ 'For displaying the column name in the the excel file.
¤ For intColumn = 0 To dsExcelExport.Tables(0).Columns.Count - 1
¤ .Cells(1, intColumn + 1).Value =
¤ dsExcelExport.Tables(0).Columns(intColumn).ColumnN ame.ToString
¤ Next
¤ 'For displaying the column value row-by-row in the the excel
¤ file.
¤ For intRow = 0 To dsExcelExport.Tables(0).Rows.Count - 1
¤ For intColumnValue = 0 To
¤ dsExcelExport.Tables(0).Columns.Count - 1
¤ .Cells(intRow + 1, intColumnValue + 1).Value =
¤ dsExcelExport.Tables(0).Rows(intRow).ItemArray(int ColumnValue).ToString
¤ Next
¤ Next
¤

What is the data source of your export?
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #3
MS SQL Server
"Paul Clement" <Us***********************@swspectrum.com>
???????:hq********************************@4ax.com ...
On Tue, 25 Oct 2005 18:15:54 +0800, "Agnes" <ag***@dynamictech.com.hk>
wrote:

¤ I can export the data to excel, but it is really really slow. need 5-6
mins
¤ to export 30 fields (a hundred records) . for my old vfp application,
less
¤ than 3 minutes. for 500-800 records.
¤ Does any idea to improve the alog ?? Or what Can I do in my sql server ?
¤ Thanks a lot
¤
¤ 'For displaying the column name in the the excel file.
¤ For intColumn = 0 To dsExcelExport.Tables(0).Columns.Count -
1
¤ .Cells(1, intColumn + 1).Value =
¤ dsExcelExport.Tables(0).Columns(intColumn).ColumnN ame.ToString
¤ Next
¤ 'For displaying the column value row-by-row in the the excel
¤ file.
¤ For intRow = 0 To dsExcelExport.Tables(0).Rows.Count - 1
¤ For intColumnValue = 0 To
¤ dsExcelExport.Tables(0).Columns.Count - 1
¤ .Cells(intRow + 1, intColumnValue + 1).Value =
¤ dsExcelExport.Tables(0).Rows(intRow).ItemArray(int ColumnValue).ToString
¤ Next
¤ Next
¤

What is the data source of your export?
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 21 '05 #4
On Wed, 26 Oct 2005 18:02:31 +0800, "Agnes" <ag***@dynamictech.com.hk> wrote:

¤ MS SQL Server

How about the following code (table format is assumed to be the same or column names will need to be
specified):

Function ExportExcelToSQLServer() As Boolean

Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My
Documents\Book5.xls" & ";" & _
"Extended Properties=""Excel
8.0;HDR=No""")

ExcelConnection.Open()

'Existing table
Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("INSERT INTO [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_ Connection=yes].[Orders2] SELECT * FROM
[Orders$];", ExcelConnection)
'New table
'Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("SELECT INTO [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_ Connection=yes].[Orders2] FROM [Orders$];",
ExcelConnection)

ExcelCommand.ExecuteNonQuery()
ExcelConnection.Close()

End Function
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
0
by: Nik | last post by:
I have a VB.NET Web application. I have to export data from SQL Server to excel. I have 3 Select statements and the results need to go in 3 separate worksheets and the column headers of the sheets...
4
by: Tomek | last post by:
Hi, How could I export data from table or query to excel file in VB.NET? Thanks in advance, Tomek
2
by: Agnes | last post by:
I can export the data to an excel(quit slow , for 5k records, It need 20mins) Now, my problem is how can I join another table from another database ? "select I.invno,I.company,C.telno,C.faxno from...
4
by: Jiro Hidaka | last post by:
Hello, I would like to know of a fast way to export data source data into an Excel sheet. I found a way from C# Corner(Query Tool to Excel using C# and .NET) which is a neat little way of...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
1
by: Pauline | last post by:
Dear all, I have an enormous database (Access 2003) containing sales information, and an Excel tool to enable end users to do planning and forecasting. Untill now I would create several queries,...
19
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
5
by: Reggie | last post by:
Hi and TIA! I have an export procedure that exports my data from my datagrids to excel. The problem is that I lose leading zero's cause excel removes them and doesn't treat them as text. Is it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.