将网格导出为沙盒解决方案中的excel [英] Exporting grid to excel in sandbox solution

查看:65
本文介绍了将网格导出为沙盒解决方案中的excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何从沙盒解决方案中为Microsoft在线导出excel格式。

如果你知道它很快就会帮助我。



谢谢。

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.

Thanks.

推荐答案



我认为你应该阅读讨论1 [ ^ ]和讨论2 [ ^ ]







--Amit
Hi,
As I think you should read discussion1[^] and discussion2 [^]



--Amit


你好,

请试试这个,

按钮:< asp:按钮runat =serverid =btnExporttext =导出onclick =btnExport_Clickonclientclick =_ spFormOnSubmitCalled =假; _spSuppressFormOnSubmitWrapper = TRUE; xmlns:asp =#unknown>



按钮单击事件:

HttpContext.Current.Response.Clear();

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)

{

table.Rows.Add(myGrid.HeaderRow);

}



foreach(GridV iew在myGrid.Rows中的行。

{

table.Rows.Add(row);

}

table.RenderControl(htw);

HttpContext.Current.Response.Write(writer.ToString());

HttpContext.Current.Response.End();

}

}
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.Clear();
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)
{
table.Rows.Add(myGrid.HeaderRow);
}

foreach (GridViewRow row in myGrid.Rows)
{
table.Rows.Add(row);
}
table.RenderControl(htw);
HttpContext.Current.Response.Write(writer.ToString());
HttpContext.Current.Response.End();
}
}


Sandbox存在于它自己的进程中,HttpContext.Current与ASP.NET中的HttpContext.Current不同(它位于IIS和W3WP.exe进程中。)



无法使用解决方案导出到网格中的excel。
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.


这篇关于将网格导出为沙盒解决方案中的excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆