table里的部分行和列被合并了。导出的时候合并过的列可以完全导出。但是合并的行却不见了。行和列的合并都是经过系统自动生成的。如果把合并的行给分开就会完全导出没有错误。郁闷!!!找到问题点却没找到解决方法。各位高手给小弟指点一下吧!!!!
在线等待……………………

解决方案 »

  1.   

    Response.Clear();
    Response.Buffer= true; 
    Response.Charset="UTF-7";
    Response.AppendHeader("Content-Disposition","attachment;filename=TrialMap.xls"); //online
    Response.ContentEncoding=System.Text.Encoding.GetEncoding("UTF-7");  
    this.EnableViewState = false;
    System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
    tblTest.RenderControl(oHtmlTextWriter);
    Response.Write(oStringWriter.ToString()); 
    Response.End();
    这是导出数据的代码!!从网上学的。
    public void spanRow(Table dgModify,int spancell,int spanby,int spand)
    {
    if(spanby<0||spanby>dgModify.Rows.Count)
    {
    return;
    }
    int rowspan = 1;
    for(int i=1;i<dgModify.Rows.Count;i++)
    {
    if(dgModify.Rows[i-1].Cells[spand].Text == dgModify.Rows[i].Cells[spand].Text)
    {
    if(dgModify.Rows[i-1].Cells [spanby].Text == dgModify.Rows[i].Cells [spanby].Text)
    {
    rowspan +=1;
    dgModify.Rows[i].Cells [spancell].Visible =false;
    dgModify.Rows[i-rowspan+1].Cells [spancell].RowSpan = rowspan;
    }
    else
    {
    string str = dgModify.Rows [i].Cells [spanby].Text;
    string str1 = dgModify.Rows[i-1].Cells [spanby].Text;
    rowspan=1;
    }
    dgModify.Rows [i].Cells[spancell].Width =Unit.Percentage(0.3);
    }
    else
    {
    rowspan = 1;
    }
    }
    }
    这是用来进行行的合并的代码!!!