Files
AutoBOM/VBA/ClassModules/clsErrorLogger.cls
Misaka_Company 58e84ddd25
All checks were successful
NTFY Notification / notify (push) Successful in 4s
feat: restore VBA source code modules
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 11:07:36 +08:00

55 lines
1.8 KiB
OpenEdge ABL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
' ==============================================================================
' 类模块: 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