-
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:10k
源码类别:

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{DD44C0E7-B2CF-11D1-8DD3-444553540000}#1.0#0"; "CELL32.OCX"
  3. Begin VB.Form frm_sjzz 
  4.    Caption         =   "数据转置"
  5.    ClientHeight    =   4575
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   6840
  9.    HelpContextID   =   1014004
  10.    Icon            =   "数据转置.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   4575
  15.    ScaleWidth      =   6840
  16.    StartUpPosition =   1  '所有者中心
  17.    Begin VB.Frame Frame1 
  18.       Caption         =   "公式选项"
  19.       Height          =   1065
  20.       Left            =   5400
  21.       TabIndex        =   6
  22.       Top             =   120
  23.       Width           =   1335
  24.       Begin VB.OptionButton Option2 
  25.          Caption         =   "返回结果"
  26.          Height          =   255
  27.          Left            =   120
  28.          TabIndex        =   8
  29.          Top             =   630
  30.          Width           =   1095
  31.       End
  32.       Begin VB.OptionButton Option1 
  33.          Caption         =   "返回公式"
  34.          Height          =   375
  35.          Left            =   120
  36.          TabIndex        =   7
  37.          Top             =   240
  38.          Value           =   -1  'True
  39.          Width           =   1095
  40.       End
  41.    End
  42.    Begin VB.CommandButton Command5 
  43.       Caption         =   "复原"
  44.       Height          =   375
  45.       Left            =   5550
  46.       TabIndex        =   5
  47.       Top             =   3180
  48.       Width           =   1095
  49.    End
  50.    Begin VB.CommandButton Command4 
  51.       Caption         =   "取消(&C)"
  52.       Height          =   375
  53.       Left            =   5550
  54.       TabIndex        =   4
  55.       Top             =   4080
  56.       Width           =   1095
  57.    End
  58.    Begin VB.CommandButton Command3 
  59.       Caption         =   "确定(&O)"
  60.       Height          =   375
  61.       Left            =   5550
  62.       TabIndex        =   3
  63.       Top             =   3630
  64.       Width           =   1095
  65.    End
  66.    Begin VB.CommandButton Command2 
  67.       Caption         =   "行反向"
  68.       Height          =   375
  69.       Left            =   5550
  70.       TabIndex        =   2
  71.       Top             =   2730
  72.       Width           =   1095
  73.    End
  74.    Begin VB.CommandButton Command1 
  75.       Caption         =   "列反向"
  76.       Height          =   375
  77.       Left            =   5550
  78.       TabIndex        =   1
  79.       Top             =   2280
  80.       Width           =   1095
  81.    End
  82.    Begin CELLLib.Cell Cell1 
  83.       Height          =   4335
  84.       Left            =   120
  85.       TabIndex        =   0
  86.       Top             =   120
  87.       Width           =   5175
  88.       _Version        =   65536
  89.       _ExtentX        =   9128
  90.       _ExtentY        =   7646
  91.       _StockProps     =   0
  92.    End
  93. End
  94. Attribute VB_Name = "frm_sjzz"
  95. Attribute VB_GlobalNameSpace = False
  96. Attribute VB_Creatable = False
  97. Attribute VB_PredeclaredId = True
  98. Attribute VB_Exposed = False
  99. '***********************************************
  100. '*    模 块 名 称 :数据转置
  101. '*    功 能 描 述 :
  102. '*    程序员姓名  :奚俊峰
  103. '*    最后修改人  :奚俊峰
  104. '*    最后修改时间:2002/01/21
  105. '***********************************************
  106. Option Explicit
  107. Private Sub Command1_Click()
  108.     Dim i As Long, j As Long, ll_cols As Long, ll_rows As Long
  109.     Dim lvar_data1, lvar_data2, ll_cell1 As Long, ll_cell2 As Long '标记是否为公式,0公式,1数据
  110.     ll_cols = Cell1.Cols
  111.     ll_rows = Cell1.Rows
  112.     For i = 0 To ll_cols  2 - 1
  113.         For j = 0 To ll_rows - 1
  114.             
  115.             If Cell1.IsFormulaCell(i, j) Then
  116.                 Cell1.DoGetFormula i, j, lvar_data1
  117.                 ll_cell1 = 0
  118.             Else
  119.                 Cell1.DoGetCellData i, j, lvar_data1
  120.                 ll_cell1 = 1
  121.             End If
  122.             If Cell1.IsFormulaCell(ll_cols - i - 1, j) Then
  123.                 Cell1.DoGetFormula ll_cols - i - 1, j, lvar_data2
  124.                 ll_cell2 = 0
  125.             Else
  126.                 Cell1.DoGetCellData ll_cols - i - 1, j, lvar_data2
  127.                 ll_cell2 = 1
  128.             End If
  129.             If ll_cell1 = 0 Then
  130.                 Cell1.DoClearCell ll_cols - i - 1, j, 0
  131.                 Cell1.DoSetFormula ll_cols - i - 1, j, lvar_data1
  132.             Else
  133.                 If lvar_data1 = "" Then
  134.                     Cell1.DoClearCell ll_cols - i - 1, j, 0
  135.                     Cell1.DoClearCell ll_cols - i - 1, j, 0
  136.                 Else
  137.                     Cell1.DoClearCell ll_cols - i - 1, j, 0
  138.                     Cell1.DoSetCellData ll_cols - i - 1, j, lvar_data1
  139.                 End If
  140.             End If
  141.             If ll_cell2 = 0 Then
  142.                 Cell1.DoClearCell i, j, 0
  143.                 Cell1.DoSetFormula i, j, lvar_data2
  144.             Else
  145.                 If lvar_data2 = "" Then
  146.                     Cell1.DoClearCell i, j, 0
  147.                     Cell1.DoClearCell i, j, 0
  148.                 Else
  149.                     Cell1.DoClearCell i, j, 0
  150.                     Cell1.DoSetCellData i, j, lvar_data2
  151.                 End If
  152.             End If
  153.             
  154.         Next j
  155.     Next i
  156.     Cell1.DoCalculateAll
  157.     Cell1.DoRedrawAll
  158. End Sub
  159. Private Sub command2_Click()
  160.     Dim i As Long, j As Long, ll_cols As Long, ll_rows As Long
  161.     Dim lvar_data1, lvar_data2, ll_cell1 As Long, ll_cell2 As Long '标记是否为公式,0公式,1数据
  162.     ll_cols = Cell1.Cols
  163.     ll_rows = Cell1.Rows
  164.     For i = 0 To ll_rows  2 - 1
  165.         For j = 0 To ll_cols - 1
  166.             
  167.             If Cell1.IsFormulaCell(j, i) Then
  168.                 Cell1.DoGetFormula j, i, lvar_data1
  169.                 ll_cell1 = 0
  170.             Else
  171.                 Cell1.DoGetCellData j, i, lvar_data1
  172.                 ll_cell1 = 1
  173.             End If
  174.             If Cell1.IsFormulaCell(j, ll_rows - i - 1) Then
  175.                 Cell1.DoGetFormula j, ll_rows - i - 1, lvar_data2
  176.                 ll_cell2 = 0
  177.             Else
  178.                 Cell1.DoGetCellData j, ll_rows - i - 1, lvar_data2
  179.                 ll_cell2 = 1
  180.             End If
  181.             If ll_cell1 = 0 Then
  182.                 Cell1.DoClearCell j, ll_rows - i - 1, 0
  183.                 Cell1.DoSetFormula j, ll_rows - i - 1, lvar_data1
  184.             Else
  185.                 If lvar_data1 = "" Then
  186.                     Cell1.DoClearCell j, ll_rows - i - 1, 0
  187.                     Cell1.DoClearCell j, ll_rows - i - 1, 0
  188.                 Else
  189.                     Cell1.DoClearCell j, ll_rows - i - 1, 0
  190.                     Cell1.DoSetCellData j, ll_rows - i - 1, lvar_data1
  191.                 End If
  192.             End If
  193.             If ll_cell2 = 0 Then
  194.                 Cell1.DoClearCell j, i, 0
  195.                 Cell1.DoSetFormula j, i, lvar_data2
  196.             Else
  197.                 If lvar_data2 = "" Then
  198.                     Cell1.DoClearCell j, i, 0
  199.                     Cell1.DoClearCell j, i, 0
  200.                 Else
  201.                     Cell1.DoClearCell j, i, 0
  202.                     Cell1.DoSetCellData j, i, lvar_data2
  203.                 End If
  204.             End If
  205.             
  206.         Next j
  207.     Next i
  208.     Cell1.DoCalculateAll
  209.     Cell1.DoRedrawAll
  210. End Sub
  211. Private Sub Command3_Click()
  212.     Dim ll_col_begin, ll_row_begin
  213.     Dim ll_col_end, ll_row_end
  214.     Dim i As Long, j As Long
  215.     Dim lvar_data
  216.     With MDI_frame.ActiveForm
  217.         .Cell1.DoGetSelectRange ll_col_begin, ll_row_begin, ll_col_end, ll_row_end
  218.         
  219.         For i = 0 To ll_col_end - ll_col_begin
  220.             For j = 0 To ll_row_end - ll_row_begin
  221.                 .Cell1.DoClearCell i + ll_col_begin, j + ll_row_begin, 0
  222.                 .Cell1.DoClearCell i + ll_col_begin, j + ll_row_begin, 0
  223.                 
  224.                 If Cell1.IsFormulaCell(i, j) And Option1.Value = True Then
  225.                     Cell1.DoGetFormula i, j, lvar_data
  226.                     .Cell1.DoSetFormula i + ll_col_begin, j + ll_row_begin, lvar_data
  227.                 Else
  228.                     Cell1.DoGetCellData i, j, lvar_data
  229.                     If lvar_data = "" Then
  230.                         .Cell1.DoClearCell i + ll_col_begin, j + ll_row_begin, 0
  231.                         .Cell1.DoClearCell i + ll_col_begin, j + ll_row_begin, 0
  232.                     Else
  233.                         .Cell1.DoSetCellData i + ll_col_begin, j + ll_row_begin, lvar_data
  234.                     End If
  235.                 End If
  236.             Next j
  237.         Next i
  238.         .Cell1.DoRedrawAll
  239.     End With
  240.     Unload Me
  241.     
  242. End Sub
  243. Private Sub Command4_Click()
  244.     Unload Me
  245.     
  246. End Sub
  247. Private Sub Command5_Click()
  248.     Dim ll_col_begin, ll_row_begin
  249.     Dim ll_col_end, ll_row_end
  250.     Dim i As Long, j As Long
  251.     Dim lvar_data
  252.     Cell1.CalcManaually = 0
  253.     With MDI_frame.ActiveForm
  254.         .Cell1.DoGetSelectRange ll_col_begin, ll_row_begin, ll_col_end, ll_row_end
  255.         For i = 0 To ll_col_end - ll_col_begin
  256.             For j = 0 To ll_row_end - ll_row_begin
  257.                 If .Cell1.IsFormulaCell(i + ll_col_begin, j + ll_row_begin) Then
  258.                     .Cell1.DoGetFormula i + ll_col_begin, j + ll_row_begin, lvar_data
  259.                     Cell1.DoSetFormula i, j, lvar_data
  260.                 Else
  261.                     .Cell1.DoGetCellData i + ll_col_begin, j + ll_row_begin, lvar_data
  262.                     If lvar_data = "" Then
  263.                         Cell1.DoClearCell i, j, 0
  264.                         Cell1.DoClearCell i, j, 0
  265.                     Else
  266.                         Cell1.DoSetCellData i, j, lvar_data
  267.                     End If
  268.                 End If
  269.             Next j
  270.         Next i
  271.     End With
  272.     Cell1.DoRedrawAll
  273. End Sub
  274. Private Sub Form_Load()
  275.     Dim ll_col_begin, ll_row_begin
  276.     Dim ll_col_end, ll_row_end
  277.     Dim i As Long, j As Long
  278.     Dim lvar_data
  279.     Cell1.CalcManaually = 0
  280.     With MDI_frame.ActiveForm
  281.         .Cell1.DoGetSelectRange ll_col_begin, ll_row_begin, ll_col_end, ll_row_end
  282.         Cell1.Cols = ll_col_end - ll_col_begin + 1
  283.         Cell1.Rows = ll_row_end - ll_row_begin + 1
  284.         
  285.         For i = 0 To ll_col_end - ll_col_begin
  286.             For j = 0 To ll_row_end - ll_row_begin
  287.                 If .Cell1.IsFormulaCell(i + ll_col_begin, j + ll_row_begin) Then
  288.                     .Cell1.DoGetFormula i + ll_col_begin, j + ll_row_begin, lvar_data
  289.                     Cell1.DoSetFormula i, j, lvar_data
  290.                 Else
  291.                     .Cell1.DoGetCellData i + ll_col_begin, j + ll_row_begin, lvar_data
  292.                     If lvar_data <> "" Then
  293.                         Cell1.DoSetCellData i, j, lvar_data
  294.                     End If
  295.                 End If
  296.             Next j
  297.         Next i
  298.     End With
  299. End Sub