Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataGrid Export to Excel

Reply
Thread Tools

DataGrid Export to Excel

 
 
Siva Mateti
Guest
Posts: n/a
 
      12-04-2003
I'm having some problems with exporting datagrid to
excel. First I had problems with Datagridlink buttons
(for paging and sorting), which I solved by iterating
through the datagrid and replacing all the link buttons
with literal control. Then I thought this following code
snippet would work:

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms- excel"
Response.Charset = ""
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
DataGrid2.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()

But after I run the snippet either nothing happens
or "page cannot be displayed" error occurs. I looked into
the process explorer and EXCEL.EXE seems to be running.
Also I turned the trace on to look at the content type and
I got "application/x-www-form-urlencoded".

Can anyone please explain me how to do it?

Thanks
Siva Mateti
 
Reply With Quote
 
 
 
 
Siva Mateti
Guest
Posts: n/a
 
      12-08-2003
I still could not solve my problem, but I got more
feedback. One reason I think why my code is not working
because I'm using an user control which after doing all
excel export, posts data back to the regular aspx page.
Now the aspx page is still set to receive text/html rather
than "application/vnd.ms- excel". I think it is here some
kind of conflict occuring. I couldn't figure out how to
avoid this. Hopefully someone can answer for me!

BTW, I figured out "application/x-www-form-urlencoded".

Thanks
Siva Mateti

>-----Original Message-----
>I'm having some problems with exporting datagrid to
>excel. First I had problems with Datagridlink buttons
>(for paging and sorting), which I solved by iterating
>through the datagrid and replacing all the link buttons
>with literal control. Then I thought this following code
>snippet would work:
>
> Response.Clear()
> Response.Buffer = True
> Response.ContentType = "application/vnd.ms- excel"
> Response.Charset = ""
> Me.EnableViewState = False
> Dim tw As New System.IO.StringWriter()
> Dim hw As New System.Web.UI.HtmlTextWriter(tw)
> DataGrid2.RenderControl(hw)
> Response.Write(tw.ToString())
> Response.End()
>
>But after I run the snippet either nothing happens
>or "page cannot be displayed" error occurs. I looked

into
>the process explorer and EXCEL.EXE seems to be running.
>Also I turned the trace on to look at the content type

and
>I got "application/x-www-form-urlencoded".
>
>Can anyone please explain me how to do it?
>
>Thanks
>Siva Mateti
>.
>

 
Reply With Quote
 
 
 
 
Alejandro Becker
Guest
Posts: n/a
 
      12-23-2003
look at this site
http://www.c-sharpcorner.com/Code/20...ridToExcel.asp

"Siva Mateti" <(E-Mail Removed)> wrote in message
news:f24201c3bd9a$f1ebedd0$(E-Mail Removed)...
> I still could not solve my problem, but I got more
> feedback. One reason I think why my code is not working
> because I'm using an user control which after doing all
> excel export, posts data back to the regular aspx page.
> Now the aspx page is still set to receive text/html rather
> than "application/vnd.ms- excel". I think it is here some
> kind of conflict occuring. I couldn't figure out how to
> avoid this. Hopefully someone can answer for me!
>
> BTW, I figured out "application/x-www-form-urlencoded".
>
> Thanks
> Siva Mateti
>
> >-----Original Message-----
> >I'm having some problems with exporting datagrid to
> >excel. First I had problems with Datagridlink buttons
> >(for paging and sorting), which I solved by iterating
> >through the datagrid and replacing all the link buttons
> >with literal control. Then I thought this following code
> >snippet would work:
> >
> > Response.Clear()
> > Response.Buffer = True
> > Response.ContentType = "application/vnd.ms- excel"
> > Response.Charset = ""
> > Me.EnableViewState = False
> > Dim tw As New System.IO.StringWriter()
> > Dim hw As New System.Web.UI.HtmlTextWriter(tw)
> > DataGrid2.RenderControl(hw)
> > Response.Write(tw.ToString())
> > Response.End()
> >
> >But after I run the snippet either nothing happens
> >or "page cannot be displayed" error occurs. I looked

> into
> >the process explorer and EXCEL.EXE seems to be running.
> >Also I turned the trace on to look at the content type

> and
> >I got "application/x-www-form-urlencoded".
> >
> >Can anyone please explain me how to do it?
> >
> >Thanks
> >Siva Mateti
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to Excel (Default File Type - Excel) =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?= ASP .Net 15 05-21-2009 12:01 PM
Export to excel in asp.net using excel template Grey ASP .Net 4 10-17-2007 08:08 AM
using Microsoft Excel image for Export to Excel button =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 0 12-09-2005 08:58 PM
Display a Datagrid & Export a Datagrid to Excel Paul D. Fox ASP .Net Datagrid Control 1 07-21-2005 08:38 PM
Export datagrid(with allowsorting) to Excel Cowboy \(Gregory A. Beamer\) ASP .Net 6 07-04-2003 12:21 AM



Advertisments