[水晶報表]動態設定section高度8/4

来源:互联网 发布:交友软件下载 编辑:程序博客网 时间:2024/05/05 21:08

 有一支報表格式如下:

需要採用Letter一半紙張列印,由於每張明細筆數都在2-4之間,而且簽名要顯示在下方,這就需要在代碼中動態設定section(合計區段Section11)的高度,相關代碼如下:
                       Dim report As New ReportDocument
                       ... ...
                       Dim sects As Sections=report.ReportDefinition.Sections

                        Dim sp, sp1 As String
                        Dim seq As Integer
                        sp1 = ""

                        For inta = 0 To dt.Rows.Count - 1
                            sp = dt.Rows(inta)(0)'群組
                            If sp1 <> sp And inta > 0 Then
                                seq = dt.Rows(inta - 1)(5)'明細的最後一筆的序號
                                Select Case seq
                                    Case 1
                                        sects.Item("Section11").Height = 3632
                                    Case 2
                                        sects.Item("Section11").Height = 3121
                                    Case 3
                                        sects.Item("Section11").Height = 2610
                                    Case 4
                                        sects.Item("Section11").Height = 2099
                                    Case 5
                                        sects.Item("Section11").Height = 1588
                                    Case 6
                                        sects.Item("Section11").Height = 1077
                                    Case Else
                                        sects.Item("Section11").Height = 566

                                End Select
                            End If
                            sp1 = sp

                            If inta = dt.Rows.Count - 1 Then'對最後一張進行設定
                                seq = dt.Rows(inta)(5)
                                Select Case seq
                                    Case 1
                                        sects.Item("Section11").Height = 3632
                                    Case 2
                                        sects.Item("Section11").Height = 3121
                                    Case 3
                                        sects.Item("Section11").Height = 2610
                                    Case 4
                                        sects.Item("Section11").Height = 2099
                                    Case 5
                                        sects.Item("Section11").Height = 1588
                                    Case 6
                                        sects.Item("Section11").Height = 1077
                                    Case Else
                                        sects.Item("Section11").Height = 566

                                          
  End Select
                            End If
                        Next
P.S.高度值是精確計算好的,由於目前對水晶報表自定義紙張的設定在客戶那裏尚未找到支持的方法(在我本機上可以的),所以暫且用一張Letter顯示上面各一半來進行列印,這種情況報表高度計算有個公式:顯示各區段總高度為7269*2+519=15111
注:計算式中的2表示上下2張,519表示在第二張列印時顯示的空白區段