Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / HTML

Export 2 Excel In .Net

1.08/5 (16 votes)
8 Dec 20051 min read 1   442  
Export 2 Excel

Download sourcecode
Introduction

This source used for Exporting data into To Excel ..
Just give referance and change few things .u get the result.
This one useful to both asp.net and vb.net.
Just sending parameters to procedure like datatable,filename ,filepath,column names.
Its creates the excel file data export into excel file and save into ur target folder.

  ' step 1: unzip the file
' step 2: copy the dll file into ur aplliction bin folder
' step 3: Give refernce to this .dll
' step 4: copy below code and paste into ur program, where u need this and do some modifications directory, filename..
     

        Dim dad As New SqlClient.SqlDataAdapter("select * from authors", "server=localhost;user id=sa;password=;Initial catalog=pubs;")
 Dim ds As New DataSet
        Dim obj As New Hari_Export2Excel.NameSpace_Export2Excel.Class_Export2Excel
        Dim filepath As String = "C:\TargetDirectory\" 'or server.mappath("../outputdirectory/")
        Dim filename As String = "abc.xls"
        dad.Fill(ds)

        '' Sending Header Column Names
        'Dim col() As String = {"COLUMN ONE", "COLUMN TWO", "COLUMN THREE"}
        'obj.Export2Excel_By_Srihari(filename, filepath, ds.Tables(0),  col)

        ' Default Column Names from database
        obj.Export2Excel_By_Srihari(filename, filepath, ds.Tables(0), Nothing)

        ' Accessing File from saved Path
        'Response.Redirect(filepath & filename)

 

 

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here