EXport data to Excel File

  • 10 years ago


    How to export data to excel.... currenctly for download 2000 rows i need until 8 minutes..

    How to fast export datas... the below is my current code for export data..


    daExcelExport = New System.Data.SqlClient.SqlDataAdapter(Str, MyConnection.open)


    With Excel

    .SheetsInNewWorkbook = 1



    'For displaying the column name in the the excel file.

    Dim i As Integer = 1For col = 0 To dsExcelExport.Tables(0).Columns.Count - 1

    .cells(1, i).value = dsExcelExport.Tables(0).Columns(col).ColumnName

    .cells(1, i).EntireRow.Font.Bold = True

    .cells(1, i).EntireColumn.AutoFit()

    i += 1


    'For displaying the column value row-by-row in the the excel file.

    i = 2

    Dim k As Integer = 1For col = 0 To dsExcelExport.Tables(0).Columns.Count - 1

    i = 2

    For row = 0 To dsExcelExport.Tables(0).Rows.Count - 1

    .Cells(i, k).Value = dsExcelExport.Tables(0).Rows(row).ItemArray(col)

    .cells(i, k).EntireColumn.AutoFit()

    i += 1


    k += 1


    strExcelFile = F_SaveDialog.F_SaveDialog_Location & "\" & F_SaveDialog.F_SaveDialog_FileName & ".xls"



    End With


    Excel = Nothing


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth