zoukankan      html  css  js  c++  java
  • c# 水晶报表中处理TextObject

    代码
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
     
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.ReportAppServer.ClientDoc;
    using CrystalDecisions.ReportAppServer.DataDefModel;
     
     
    public partial class _Default : System.Web.UI.Page 
    {
        
    protected ReportDocument boReportDocument;
     
     
        
    protected void Page_Load(object sender, EventArgs e)
        {
            
    if (!this.IsPostBack)
            {
                ConfigureCrystalReports();
            }
     
            CrystalReportViewer1.ReportSource 
    = Session["Report"];
     
        }
     
        
    protected void ConfigureCrystalReports()
        {
            ISCDReportClientDocument boReportClientDocument;        
            CrystalDecisions.ReportAppServer.Controllers.ReportObjectController boReportObjectController;
            CrystalDecisions.ReportAppServer.ReportDefModel.TextObject boOldTextObject, boNewTextObject;
            CrystalDecisions.ReportAppServer.ReportDefModel.Paragraph boParagraph;
            CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphFieldElement boParagraphFieldElement;
            CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphTextElement boParagraphTextElement;
            
            boReportDocument 
    = new ReportDocument();
            boReportDocument.Load(Server.MapPath(
    "CrystalReport.rpt"));
     
            boReportClientDocument 
    = boReportDocument.ReportClientDocument;        
            boReportObjectController 
    = boReportClientDocument.ReportDefController.ReportObjectController;
                   
     
            
    // Get a handle on the ReportObjectController so we can manipulate the TextObject        
            foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject boReportObject in boReportObjectController.GetAllReportObjects())
            {
                
    if (boReportObject.Kind == CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindText)
                {
                    boOldTextObject 
    = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)boReportObject;
                    boNewTextObject 
    = (CrystalDecisions.ReportAppServer.ReportDefModel.TextObject)boOldTextObject.Clone(true);
                    
                    
    // Clear out all paragraphs from the current text object
     
                    boNewTextObject.Paragraphs.RemoveAll();
     
                    
    // Create a new Paragraph to add to our TextObject
                    boParagraph = new CrystalDecisions.ReportAppServer.ReportDefModel.Paragraph();
     
                    
    // Create a new ParagraphTextElement to be added to our paragraph
                    
                    boParagraphTextElement 
    = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphTextElement();                
                    boParagraphTextElement.Text 
    = "The value of my parameter is: ";
                    boParagraph.ParagraphElements.Add(boParagraphTextElement);                
     
                    
    // Create a new ParagraphFieldElement (our parameter field) to be added to our paragraph                
                    boParagraphFieldElement = new CrystalDecisions.ReportAppServer.ReportDefModel.ParagraphFieldElement();
                    boParagraphFieldElement.Kind 
    = CrystalDecisions.ReportAppServer.ReportDefModel.CrParagraphElementKindEnum.crParagraphElementKindField;
                    boParagraphFieldElement.DataSource 
    = "{?Currency}";                
     
                    boParagraph.ParagraphElements.Add(boParagraphFieldElement);
                    
                    boNewTextObject.Paragraphs.Add(boParagraph);
                    
                    boReportObjectController.Modify(boOldTextObject, boNewTextObject);
     
                    
    break;
                }
            }
     
            Session.Add(
    "Report", boReportDocument);
        }
    }


    继续追寻。。。。。。
  • 相关阅读:
    Android Glide详细使用教程
    mac上cocoapods安装与卸载
    Struts2+AJAX+JQuery 实现用户登入与注册功能
    Eclipse+ADT+Android SDK 搭建安卓开发环境
    CVE-2018-7600 Drupal核心远程代码执行漏洞分析
    利用kage把msf变成可视化远控平台
    在Red Hat Enterprise Linux 7.3上安装SQL Server 2017
    计算机取证之你必须要会用的24款工具
    StackStorm利用CORS null origin获得RCE (CVE-2019-9580)
    iOS/OSX漏洞分析和再现:CVE-2019-7286
  • 原文地址:https://www.cnblogs.com/lfzwenzhu/p/1879761.html
Copyright © 2011-2022 走看看