当我尝试编辑现有的Excel文件时,我不断收到以下错误消息:
指数超出范围。必须是非负数且小于集合的大小。“& vbCrLf&”参数名称:index
代码:
Dim file As New FileInfo(Path)
Dim objXLApp = New ExcelPackage(file)
Dim objXLWs = objXLApp.Workbook.Worksheets("DiscreteAlarms")
Dim aantal_Rows As Integer = objXLWs.Dimension.Rows
pgb_alarm_check_File2.Maximum = aantal_Rows
Dim i As Integer
For i = 2 To aantal_Rows
Dim Alarm_Text = objXLWs.Cells(i, 3).Value
If Alarm_Text = "" Then
objXLWs.Cells(i, 3).Style.Fill.BackgroundColor.SetColor(Color.Red)
End If
pgb_alarm_check_File2.Value = i
Next
objXLApp.Save()