日期:2014-05-18  浏览次数:20614 次

比较另类的excel导出问题!!
我要导出的表格是:
<TABLE   id= "Table2 "   cellSpacing= "0 "   cellPadding= "0 "   width= "270 "   border= "0 ">
<TR>
    <TD   vAlign= "bottom "   Width= "30 ">
    <asp:Table   id= "Table3 "   runat= "server "   Width= "30px "> </asp:Table> </TD>
    <TD   vAlign= "bottom "   Width= "30 ">
    <asp:Table   id= "Table4 "   runat= "server "   Width= "30px "> </asp:Table> </TD>
</TR>
</TABLE>

其中的table3和table4中都是填充了自定义控件的:

SqlCommand   cmd=new   SqlCommand( "select   *   .... ",con);
SqlDataReader   sdr=cmd.ExecuteReader();
System.Web.UI.WebControls.TableRow   tr=new   TableRow();
while(sdr.Read())
{
System.Web.UI.WebControls.TableCell   tc=new   TableCell();
Control1   oc=(Control1)this.LoadControl( "Control_1.ascx ");
oc.ODFinf_id=sdr[ "inf_id "].ToString();
tc.Controls.Add(oc);
tr.Controls.Add(tc);
this.Table3.Rows.Add(tr);
tr=new   TableRow();
}
sdr.Close();

我现在想导出来excel表,应该怎么操作?网上搜到的都是导出datagrid和datatable的,不适合!!

------解决方案--------------------
protected override void Render(HtmlTextWriter writer)
{
Response.ContentType = "application/octet-stream ";
Response.AddHeader( "Content-Disposition ", "attatchment;filename=test.xls ");
MyReport.RenderControl(writer);
}
------解决方案--------------------
http://blog.csdn.net/wangdetian168/archive/2007/08/15/1744848.aspx
这个呢