ReportX实例(3)VB

来源:互联网 发布:淘宝卖家如何投诉买家 编辑:程序博客网 时间:2024/05/18 02:07

本例子下载地址:http://download.csdn.net/source/334323 

使用步骤:
1、注册控件ReportX.ocx(本压缩包内不包含ReportX.ocx,如果需要请到
http://download.csdn.net/source/275430下载)

代码:
Private Sub AppendCol_Click()
  ReportX1.AppendCol 1
End Sub

Private Sub AppendRow_Click()
  ReportX1.AppendRow 1
End Sub

Private Sub Copy_Click()
  Dim SelectMinx As Long
  Dim SelectMiny As Long
  Dim SelectMaxx As Long
  Dim SelectMaxy As Long
  ReportX1.GetSelectCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
  ReportX1.CopyCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
End Sub

Private Sub Cut_Click()
  Dim SelectMinx As Long
  Dim SelectMiny As Long
  Dim SelectMaxx As Long
  Dim SelectMaxy As Long
  ReportX1.GetSelectCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
  ReportX1.CutCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
End Sub

Private Sub DeleteCol_Click()
  Dim SelectMinx As Long
  Dim SelectMiny As Long
  Dim SelectMaxx As Long
  Dim SelectMaxy As Long
  ReportX1.GetSelectCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
  ReportX1.DeleteCol SelectMinx, SelectMaxx - SelectMinx + 1
End Sub

Private Sub DeleteRow_Click()
  Dim SelectMinx As Long
  Dim SelectMiny As Long
  Dim SelectMaxx As Long
  Dim SelectMaxy As Long
  ReportX1.GetSelectCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
  ReportX1.DeleteRow SelectMiny, SelectMaxy - SelectMiny + 1
End Sub


Private Sub Form_Resize()
  ReportX1.Width = Form1.Width - 120
  ReportX1.Height = Form1.Height - 1350
End Sub

Private Sub Frozen_Click()
  Dim Inputx As Long
  Dim Inputy As Long
  ReportX1.GetInputCell Inputx, Inputy
  ReportX1.SetFrozenCol ReportX1.LeftCol, Inputx - 1
  ReportX1.SetFrozenRow ReportX1.TopRow, Inputy - 1
End Sub

Private Sub InsertCol_Click()
  Dim Inputx As Long
  Dim Inputy As Long
  ReportX1.GetInputCell Inputx, Inputy
  ReportX1.InsertCol Inputx, 1
End Sub

Private Sub InsertRow_Click()
  Dim Inputx As Long
  Dim Inputy As Long
  ReportX1.GetInputCell Inputx, Inputy
  ReportX1.InsertRow Inputy, 1
End Sub

Private Sub Merge_Click()
  Dim SelectMinx As Long
  Dim SelectMiny As Long
  Dim SelectMaxx As Long
  Dim SelectMaxy As Long
  ReportX1.GetSelectCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
  ReportX1.MergeCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
End Sub

Private Sub New_Click()
  ReportX1.NewReport 30, 100
End Sub

Private Sub NoFrozen_Click()
  ReportX1.SetFrozenCol 0, 0
  ReportX1.SetFrozenRow 0, 0
End Sub

Private Sub Open_Click()
  CommonDialog1.ShowOpen
  If CommonDialog1.FileName <> "" Then
    ReportX1.OpenReport CommonDialog1.FileName
  End If
End Sub

Private Sub PageSetup_Click()
  ReportX1.PrintSetup
End Sub

Private Sub Paste_Click()
  Dim Inputx As Long
  Dim Inputy As Long
  ReportX1.GetInputCell Inputx, Inputy
  ReportX1.Paste Inputx, Inputy, True
End Sub

Private Sub Preview_Click()
  ReportX1.Preview
End Sub

Private Sub Print_Click()
  ReportX1.Print True
End Sub

Private Sub Save_Click()
  CommonDialog1.ShowSave
  If CommonDialog1.FileName <> "" Then
    ReportX1.SaveReport CommonDialog1.FileName
  End If
End Sub

Private Sub SetScript_Click()
  Dim Inputx As Long
  Dim Inputy As Long
  ReportX1.GetInputCell Inputx, Inputy
  ReportX1.EditCellScript Inputx, Inputy
End Sub

Private Sub Split_Click()
  Dim SelectMinx As Long
  Dim SelectMiny As Long
  Dim SelectMaxx As Long
  Dim SelectMaxy As Long
  ReportX1.GetSelectCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
  ReportX1.SplitCell SelectMinx, SelectMiny, SelectMaxx, SelectMaxy
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  Select Case (Button.Index)
    Case 1:
      New_Click
    Case 2:
      Open_Click
    Case 3:
      Save_Click
    Case 5:
      PageSetup_Click
    Case 6:
      Preview_Click
    Case 7:
      ReportX1.Print False
    Case 9:
      Cut_Click
    Case 10:
      Copy_Click
    Case 11:
      Paste_Click
    Case 13
      Merge_Click
    Case 14
      Split_Click
    Case 16:
      InsertCol_Click
    Case 17
      InsertRow_Click
    Case 18:
      DeleteCol_Click
    Case 19
      DeleteRow_Click
    Case 20:
      AppendCol_Click
    Case 21:
      AppendRow_Click
    Case 23:
      SetScript_Click
    Case 25:
      Frozen_Click
  End Select
End Sub