feat: restore VBA source code modules
All checks were successful
NTFY Notification / notify (push) Successful in 4s

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-02-04 11:07:36 +08:00
parent 25f6ae29ac
commit 58e84ddd25
7 changed files with 899 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
' ==============================================================================
' 类模块: clsErrorLogger
' 职责: 错误日志记录器 (修正版移除UDT使用数组存储)
' ==============================================================================
Option Explicit
Private pErrors As Collection
Private Sub Class_Initialize()
Set pErrors = New Collection
End Sub
' 记录错误
Public Sub Record(RowIndex As Long, SourceFunc As String, ErrorType As String, Desc As String, Context As String)
' 使用数组存储单条错误信息:行号, 来源, 类型, 描述, 上下文
pErrors.Add Array(RowIndex, SourceFunc, ErrorType, Desc, Context)
End Sub
' 是否有错误
Public Property Get HasErrors() As Boolean
HasErrors = (pErrors.count > 0)
End Property
'
Public Sub PrintReport(targetWb As Workbook)
If pErrors.count = 0 Then Exit Sub
Dim ws As Worksheet
Set ws = targetWb.Worksheets.Add(After:=targetWb.Worksheets(targetWb.Worksheets.count))
ws.Name = "错误报告_" & Format(Now, "hhmmss")
'
ws.Range("A1:E1").Value = Array("原表行号", "来源模块", "错误类型", "详细描述", "原始数据")
ws.Range("A1:E1").Font.Bold = True
ws.Range("A1:E1").Interior.Color = RGB(255, 200, 200)
'
Dim arrOutput() As Variant
ReDim arrOutput(1 To pErrors.count, 1 To 5)
Dim i As Long
Dim vItem As Variant
For i = 1 To pErrors.count
vItem = pErrors(i)
arrOutput(i, 1) = vItem(0)
arrOutput(i, 2) = vItem(1)
arrOutput(i, 3) = vItem(2)
arrOutput(i, 4) = vItem(3)
arrOutput(i, 5) = vItem(4)
Next i
ws.Range("A2").Resize(UBound(arrOutput, 1), 5).Value = arrOutput
ws.Columns.AutoFit
End Sub