• ASP.NET(VB.NET)网页中输出水晶报表



        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
                '1.创建报表文件
                Dim myReport As ReportDocument = New ReportDocument()
                '2.取到报表文件的物理路径
                Dim reportPath As String = Server.MapPath("~/RES/secCheckReport.rpt")
                '3.加载报表文件
                myReport.Load(reportPath)
                ''准备报表数据源
                Dim dtScdPrint As DataTable = SecCheckDec.dtScd
                '4自定义报表头部所需要的参数
                Dim vOpeAgtName As String = ""
                Dim vAwbAgtName As String = ""
                Dim vAwbNo As String = ""
                Dim vDate As String = ""
                Dim vQualification As String = ""
                If dtScdPrint.Rows.Count > 0 Then ''打印时只能打印指定运单号的安检申报清单,故取第一条记录获取其中的信息
                    Dim rowScd As DataRow = dtScdPrint.Rows(0)
                    vOpeAgtName = SafeString(rowScd.Item("HANDLEAGTNAME"), "")
                    vAwbAgtName = SafeString(rowScd.Item("OWNERAGTNAME"), "")
                    vAwbNo = rowScd.Item("AWBPFX") + "-" + rowScd.Item("AWBNUM")
                    vDate = DateTime.Now.ToString("yyyy-MM-dd")
                    vQualification = ""
                End If
                '5将定义好的报表头参数传入报表
                '5.1定义ParameterFields
                Dim paramfields As ParameterFields = New ParameterFields()

                '5.2设置在报表中,将要接受参数字段的名称
                Dim pfHash As Hashtable = New Hashtable
                pfHash.Add("strOpeAgtName", vOpeAgtName)
                pfHash.Add("strAwbAgtName", vAwbAgtName)
                pfHash.Add("strAwbNo", vAwbNo)
                pfHash.Add("strDate", vDate)
                pfHash.Add("strQualification", vQualification)
                For Each item As System.Collections.DictionaryEntry In pfHash
                    Dim paramfield As ParameterField = New ParameterField()
                    Dim p_arg As ParameterDiscreteValue = New ParameterDiscreteValue()
                    paramfield.ParameterFieldName = item.Key.ToString()
                    p_arg.Value = item.Value.ToString()
                    paramfield.CurrentValues.Add(p_arg)
                    paramfields.Add(paramfield)
                Next

                '6.将参数集合绑定到报表浏览控件
                Me.CrystalReportViewer1.ParameterFieldInfo = paramfields
                '7.为报表设置新的数据源
                myReport.SetDataSource(SecCheckDec.dtScd)
                '8.将创建你的新的报表文档绑定
                Me.CrystalReportViewer1.ReportSource = myReport
                Me.CrystalReportViewer1.DataBind()

            Catch ex As Exception
                Call (New CargoException("", ex)).AppendToLog()
            End Try
        End Sub
    End Class

  • 相关阅读:
    Spring 发生 has not been refreshed yet 异常
    rsyslog config
    grok
    阿里云态势
    Unity的asm笔记
    Unity2020或Unity2019安装后无法启动
    rider代码折叠
    使用rider调试lua
    MacType更好的字体渲染
    Unity字体和画面花屏处理
  • 原文地址:https://www.cnblogs.com/xhety/p/3314408.html
Copyright © 2020-2023  润新知