Click here to Skip to main content
15,880,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is any one know how to export excel from grid view in sandbox solution for Microsoft online.
If you know it kindly help me soon.


As I think you should read discussion1[^] and discussion2 [^]

Share this answer
sugumaran srinuvasan 4-Aug-12 2:14am    
So still there is no solution for this issue?
_Amy 4-Aug-12 2:17am    
I am not having a clear idea about it. Before a long time I read this. I thought this may help you. That's why I posted those links here. :)
sugumaran srinuvasan 4-Aug-12 3:10am    
that links not given a solution. i have already saw that posts.. thanks for the help amy.
Hello ,
Please try this,
Button: <asp:button runat="server" id="btnExport" text="Export" onclick="btnExport_Click" onclientclick="_spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;" xmlns:asp="#unknown">

Button Click Event:
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=Download.xls"));
HttpContext.Current.Response.ContentType = "application/ms-excel";
using (StringWriter writer = new StringWriter())
using (HtmlTextWriter htw = new HtmlTextWriter(writer))
Table table = new Table();
table.GridLines = myGrid.GridLines;
if (myGrid.HeaderRow != null)

foreach (GridViewRow row in myGrid.Rows)
Share this answer
sugumaran srinuvasan 4-Aug-12 3:11am    
i am getting null reference error in above coding @ HttpContext.Current.
I am using sandbox solution ..
The Sandbox lives in it's own process and the HttpContext.Current is different from the HttpContext.Current in ASP.NET (that lives in IIS and the W3WP.exe process).

It's not possible to use the solution for export to excel from grid.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900