我找了这段代码,但是貌似只能恢复一次,不能连续恢复啊。。。
02.Public Class clearRangeAction
03. Inherits FarPoint.Win.Spread.UndoRedo.UndoAction
04.
05. Dim sheetView As FarPoint.Win.Spread.SheetView
06. Dim cellRange As FarPoint.Win.Spread.Model.CellRange
07. Dim rowInfo As FarPoint.Win.Spread.RowClipInfoRange
08. Dim columnInfo As FarPoint.Win.Spread.ColumnClipInfoRange
09. Dim cellInfo As FarPoint.Win.Spread.CellInfoRange
10.
11. Public Sub New()
12.
13. End Sub
14.
15. Public Sub New(ByVal sheetView As FarPoint.Win.Spread.SheetView, ByVal cellRange As FarPoint.Win.Spread.Model.CellRange)
16. Me.sheetView = sheetView
17. Me.cellRange = cellRange
18. End Sub
19.
20. Public Overrides Function PerformUndoAction(ByVal sender As Object) As Boolean
21. Dim spreadView As FarPoint.Win.Spread.SpreadView = Nothing
22. If TypeOf sender Is FarPoint.Win.Spread.SpreadView Then
23. spreadView = CType(sender, FarPoint.Win.Spread.SpreadView)
24. Else
25. Return False
26. End If
27.
28. If sheetView Is Nothing Then
29. sheetView = spreadView.GetSheetView
30. End If
31. If (SaveUndoState()) And Not (sheetView Is Nothing) Then
32. sheetView.ClearRange(cellRange.Row, cellRange.Column, cellRange.RowCount, cellRange.ColumnCount, False)
33. Return True
34. End If
35. Return False
36. End Function
37.
38. Protected Overrides Function SaveUndoState() As Boolean
39. If Not (sheetView Is Nothing) Then
40. If cellRange Is Nothing Then
41. cellRange = sheetView.GetSelection(0)
42. If cellRange Is Nothing Then
43. cellRange = New FarPoint.Win.Spread.Model.CellRange(sheetView.ActiveRowIndex, sheetView.ActiveColumnIndex, 1, 1)
44. End If
45. End If
46. If Not (cellRange Is Nothing) Then
47. If (cellRange.IsValidRange(sheetView, False)) Then
48. cellInfo = FarPoint.Win.Spread.CellInfoRange.FromCellRange(sheetView, cellRange, rowInfo, columnInfo)
49. End If
50. End If
51. End If
52. Return Not (cellInfo Is Nothing)
53. End Function
54.
55. Public Overrides Function Undo(ByVal sender As Object) As Boolean
56. Dim spreadView As FarPoint.Win.Spread.SpreadView = Nothing
57. If TypeOf sender Is FarPoint.Win.Spread.SpreadView Then
58. spreadView = CType(sender, FarPoint.Win.Spread.SpreadView)
59. Else
60. Return False
61. End If
62.
63. If (cellRange.IsValidRange(sheetView, False)) Then
64. If Not (cellInfo Is Nothing) Then
65. Dim dataObject As New DataObject()
66. dataObject.SetData(cellInfo)
67. If Not (columnInfo Is Nothing) Then
68. dataObject.SetData(columnInfo)
69. End If
70. If Not (rowInfo Is Nothing) Then
71. dataObject.SetData(rowInfo)
72. End If
73. If Not (sheetView.ActiveRowIndex = cellRange.Row) Or Not (sheetView.ActiveColumnIndex = cellRange.Column) Then
74. sheetView.SetActiveCell(cellRange.Row, cellRange.Column)
75. End If
76. sheetView.ClipboardPaste(FarPoint.Win.Spread.ClipboardPasteOptions.All, dataObject)
77. Return True
78. End If
79. End If
80. Return False
81.
82. End Function
83.
84.End Class
|