Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...how to export grid view to excel format ?how to export grid view to excel format ?
Previous
 
Next
New Post
6/22/2006 4:01 AM
 

Hai

Can any one tell how to export grid view to the excel sheet ?

Regards,

Ganapathy.L

 
New Post
6/22/2006 9:08 AM
 

Try this and see if it works. I keep the data grid on a seperate control, with nothing else on that page. 

This is what I do, and it works well:

Public Sub ExporttoExcel()

Response.Clear()

Response.AddHeader("content-disposition", "attachment;filename=MyFile.xls")

Response.Charset = ""

Response.Cache.SetCacheability(HttpCacheability.NoCache)

Response.ContentType = "application/vnd.xls"

Dim stringWrite As New System.IO.StringWriter

Dim htmlWrite As New HtmlTextWriter(stringWrite)

grdMyGrid.RenderControl(htmlWrite)

Response.Write(stringWrite.ToString())

Response.End()

'Response.Redirect(NavigateURL(), True)

End Sub

 
New Post
6/24/2006 1:10 AM
 

Thanks for poting ech01

when i am using the above code

i am gettting error on buton click

following is the eror message:

AssemblyVersion: 04.00.03
Method: System.Web.UI.Page.VerifyRenderingInServerForm
FileName:
FileLineNumber: 0
FileColumnNumber: 0
PortalID: 0
PortalName: My Website
UserID: -1
UserName:
ActiveTabID: 36
ActiveTabName: Home
AbsoluteURL: /layer/Default.aspx
AbsoluteURLReferrer: http://localhost:1192/layer/Default.aspx
ExceptionGUID: 9c7fd257-c708-436a-b738-d230d58d2496
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
InnerException: Control 'dnn_ctr365_ViewGuestBook_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
Message: DotNetNuke.Services.Exceptions.PageLoadException: Control 'dnn_ctr365_ViewGuestBook_GridView1' of type 'GridView' must be placed inside a form tag with runat=server. ---> System.Web.HttpException: Control 'dnn_ctr365_ViewGuestBook_GridView1' of type 'GridView' must be placed inside a form tag with runat=server. at System.Web.UI.Page.VerifyRenderingInServerForm(Control control) at System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer, Boolean renderPanel) at System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at YourCompany.Modules.GuestBook.ViewGuestBook.ExporttoExcel() in C:\Documents and Settings\Gaanpati\Desktop\layer\layer\DesktopModules\GuestBook\ViewGuestBook.ascx.vb:line 86 at YourCompany.Modules.GuestBook.ViewGuestBook.b1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Gaanpati\Desktop\layer\layer\DesktopModules\GuestBook\ViewGuestBook.ascx.vb:line 98 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
StackTrace:
Source:
Server Name: GANPATI

 

description of module,

This module contain the grid view control with paging of 50

athore than the grid view we having one button in the module ,on button click event i pasted the above coding for exporting grid view to exel sheet. but iam getting error.

 


 
New Post
6/25/2006 2:32 AM
 

Check out this post, I think it has what you need.

 


Bilal Al-Ghazi
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...how to export grid view to excel format ?how to export grid view to excel format ?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out