Click here to Skip to main content
11,706,979 members (57,694 online)
Click here to Skip to main content

Export 2 Excel In .Net

, 8 Dec 2005 68.5K 369 18
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

hari_ksa
Web Developer
Malaysia Malaysia
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralCreate nicely formatted Excel files Pin
aron.sinoai22-Apr-11 9:56
memberaron.sinoai22-Apr-11 9:56 
Generalneed help Pin
NHadizadeh25-Mar-09 19:12
memberNHadizadeh25-Mar-09 19:12 
GeneralAlternative import/export Pin
BarbaMariolino15-May-08 21:44
memberBarbaMariolino15-May-08 21:44 
GeneralobjCells not declared Pin
cookie king6-May-08 10:55
membercookie king6-May-08 10:55 
GeneralHi need help ! Pin
Jagdish aher24-Sep-07 0:15
memberJagdish aher24-Sep-07 0:15 
GeneralRe: Hi need help ! Pin
hari_ksa24-Sep-07 19:33
memberhari_ksa24-Sep-07 19:33 
GeneralBasically a CSV Export. Why not SpreadsheetML Pin
John Crocker8-Dec-05 22:23
memberJohn Crocker8-Dec-05 22:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 9 Dec 2005
Article Copyright 2005 by hari_ksa
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid