明细表中经常会出现部分行有公式部分行没有公式,而非整列都有公式,在填报时需要将非整列有公式的单元格也锁定,可以简单的通过VBA来实现控制,下面的语句复制粘贴在您模版中的VBA中,将里面的明细表区域替换为您的明细表区域.
- Imports SpreadsheetGear
- Imports C1.Silverlight
- Imports C1.Silverlight.C1MessageBoxButton
- Imports C1.Silverlight.C1MessageBoxIcon
- Imports Newtonsoft.Json
- Imports Newtonsoft.Json.Linq
- Imports System.Windows.forms
- Namespace ExcelViewVBDotnet
- Public Class StandardInterface
- '预留位置1
- '预留位置2
- Dim EV As SpreadsheetGear.Windows.Controls.WorkbookView,AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
- Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Controls.WorkbookView)
- EV = Excel
- Excel.GetLock()
- AW = Excel.ActiveWorkbook
- Range = AW.ActiveWorksheet.Range
- Excel.ReleaseLock()
-
- On Error resume Next
- ActiveWorkbook.WorkbookSet.GetLock()
- If Range("ReportStatus").Text <> "查阅" Then
- Dim MyRange As IRange
- ActiveWorkbook.ActiveWorksheet.ProtectContents = False
- For Each MyRange In Range("T_74")
- If MyRange.HasFormula Then
- MyRange.Locked = True
- Else
- MyRange.Locked = False
- End If
- Next
- End If
- ActiveWorkbook.WorkbookSet.ReleaseLock()
-
-
- End Sub'打开时执行事件
- Public Sub RangeSelection(sender As Object,e As SpreadsheetGear.Windows.Controls.RangeSelectionChangedEventArgs)
- End Sub'单元格选择后执行的事件
- Public Sub RangeChanged(sender As Object,e As SpreadsheetGear.Windows.Controls.RangeChangedEventArgs)
- End Sub'单元格编辑完成后执行事件
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs)
- End Sub'按钮/标签点击事件
- Public Sub FollowHyperlink(sender As Object)
- End Sub '暂不支持
- End Class
- ' 注:除事件字眼下可以自定义代码外的所有代码不允许改动,否则编译将有可能失败。
- End Namespace
复制代码
|
|
hessen