如题

解决方案 »

  1.   

    你先在报表中加入textobject 对象,然后通过reportDocument对象就可以访问了。
    /// <summary>
    /// 填充水晶报表数据
    /// </summary>
    public void FillPrintData(string reportPath)
    {
    if (this.Parameters.ContainsKey("YSZID"))
    {
    this.YSZID = this.Parameters["YSZID"].ToString();
                    objPreSellLinence=new GESoft.FDJ.BusModules.wsba.Business.PreSellLinence(this.YSZID);
    dtBody=objPreSellLinence.GetBuildingListOfLicence().Tables[0].Copy();
    rdGrantCertificate.Load(reportPath);
    //填充预售证表格信息
    for(int row=0;row<dtBody.Rows.Count;row++)
    {
    for(int col =0;col<dtBody.Columns.Count;col++)
    {
    if(dtBody.Columns[col].ColumnName=="ZH")
    {
    string ctrName="to";
    ctrName=ctrName+row.ToString()+"0";
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects[ctrName])).Text=dtBody.Rows[row][col].ToString(); 
    }
    if(dtBody.Columns[col].ColumnName=="DMCC")
    {
    string ctrName="to";
    ctrName=ctrName+row.ToString()+"1";
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects[ctrName])).Text=dtBody.Rows[row][col].ToString(); 
    }
    if(dtBody.Columns[col].ColumnName=="FWYTMC")
    {
    string ctrName="to";
    ctrName=ctrName+row.ToString()+"2";
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects[ctrName])).Text=dtBody.Rows[row][col].ToString(); 
    }
    if(dtBody.Columns[col].ColumnName=="ZJSMJ")
    {
    string ctrName="to";
    ctrName=ctrName+row.ToString()+"3";
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects[ctrName])).Text=dtBody.Rows[row][col].ToString(); 
    }
    if(dtBody.Columns[col].ColumnName=="ZTS")
    {
    string ctrName="to";
    ctrName=ctrName+row.ToString()+"4";
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects[ctrName])).Text=dtBody.Rows[row][col].ToString(); 
    }

    }
    }
    //填充预售证表头信息
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects["toCSellerName"])).Text=objPreSellLinence.DWMC;
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects["toCProjectName"])).Text=objPreSellLinence.XMMC;
    GESoft.FDJ.BusModules.wsba.Business.Building objBuilding=new GESoft.FDJ.BusModules.wsba.Business.Building();
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects["toCLocation"])).Text=objBuilding.HouseSit(objPreSellLinence.LPZL);
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects["toCUserforlife"])).Text=objPreSellLinence.KSRQ.ToString()+"--"+objPreSellLinence.ZZRQ.ToString();
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects["toLinenceId"])).Text=objPreSellLinence.YSZH.ToString();
    ((TextObject)(rdGrantCertificate.ReportDefinition.Sections["Section3"].ReportObjects["toRe"])).Text=objPreSellLinence.BZ;
    crvGrantCertificate.PrintMode=CrystalDecisions.Web.PrintMode.ActiveX;
    crvGrantCertificate.ReportSource=rdGrantCertificate; }
      

  2.   

    建立水晶报表CR2,在CR2上放一个文本字段txtms.
    其他的看下面的代码.
    CR2 crt2=new CR2();TextObject getObjms;
    getObjms=crt2.ReportDefinition.ReportObjects["txtms"] as TextObject;
    getObjms.Text="区域销售汇总报表";
    没问题吧!要看不懂我就没法了.
      

  3.   

    TextObject  需要引用什么?
      

  4.   

    using CrystalDecisions.CrystalReports.Engine;