All checks were successful
NTFY Notification / notify (push) Successful in 20s
Rename VBA/ directory to VBA_BOMConverter/ for better clarity. This change reflects the module's purpose as the BOM converter component. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
55 lines
1.8 KiB
OpenEdge ABL
55 lines
1.8 KiB
OpenEdge ABL
' ==============================================================================
|
||
' 类模块: 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 |