Loading .xls file from a dataset.

G

Guest

greetings people,

has anyone tried to load an excel file from a dataset? meaning the source of the .xls file comes from the dataset?
 
T

Trevor Benedict R

I use a DataTable, Bind it to a DataGrid but before that I set the
Response.ContextType. So the client views is in the native application
like Excel etc

Regards,

Trevor Benedict R
MCSD

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
T

Trevor Benedict R

Here is the code

Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
'Populate the dataTable/DataSet Here
dgFGI.DataSource = dtDataTable
dgFGI.DataBind()

I used the DataGrid 'cos I needed some nice formatting to be done.

If you need to let the users download the file then add
Response.AddHeader("content-disposition", "attachment; filename=" &
strFileName)

HTH

Trevor Benedict R
MCSD

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top