PUSH模式动态水晶报表的实现-报表的纸张、反向、边距

根据设置的参数设置报表使用的纸张、反向、边距、以及报表是否居中显示的解决代码

转载请注明出处

    Private Function SetReportOPtion(ByRef CustomReport As ReportDocument, ByVal sName As String, ByRef PaperType As RepOption) As Boolean
        Dim Txt As String
        Try
            PaperType = getPaper(sName)
            Dim TotalWid As Integer = GetTotalWid(sName) '这个总宽度应该是各字段的宽度总和
            If (TotalWid + 1000) > PaperType.Wid Then '报表的边距+报表的 总宽度是否 超过纸张的总宽度
                MsgBox("报表宽度大于纸张,没法显示", MsgBoxStyle.Critical, "") '
                Return False
            End If
            Dim printOpt As CrystalDecisions.CrystalReports.Engine.PrintOptions = CustomReport.PrintOptions
            printOpt.PaperOrientation = PaperType.PaperOrigin   '方向
            printOpt.PaperSize = PaperType.Paper                '纸张
            Txt = GetINI("Report", "AutoCenter", "0", sName)
            '------------------------边距
            Dim Margen As CrystalDecisions.Shared.PageMargins
            If Txt = "1" Then
                Margen.leftMargin = (PaperType.Wid - TotalWid) / 2
                Margen.rightMargin = (PaperType.Wid - TotalWid) / 2
            Else
                Txt = GetINI("Report", "leftMargin", "1440", sName)
                Margen.leftMargin = Txt
                TotalWid = TotalWid - Txt
                Txt = GetINI("Report", "rightMargin", "1440", sName)
                Margen.rightMargin = Txt
            End If
            Txt = GetINI("Report", "topMargin", "1440", sName)
            Margen.topMargin = Txt
            Txt = GetINI("Report", "bottomMargin", "1440", sName)
            Margen.bottomMargin = Txt

            TotalWid = TotalWid - Txt
            printOpt.ApplyPageMargins(Margen)

        Catch
            MsgBox(Err.Description, MsgBoxStyle.Critical, "")
            Return False
        End Try
        Return True
    End Function

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值