Reading Excel Data in .NET
Try
xla = CreateObject("Excel.Application")
xlw = GetObject(FileName)
xls = xlw.sheets(SheetNo)
For i = StartingRow To xls.Rows.Count
For j = StartingCol To MaxCol
If Trim(xls.Cells(i, StartingCol).Text) = "" Then
GetExcelToGrid = True
GoTo EndPart
End If
Dim _Value = Trim(xls.Cells(i, j).Text)
Next j
Next i
EndPart:
DGV.AllowUserToAddRows = False
xlw.close()
xla = Nothing
xlw = Nothing
xls = Nothing
If Not IsNothing(oldCI) Then System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
Catch ex As Exception
GoTo EndPart
End Try
xla = CreateObject("Excel.Application")
xlw = GetObject(FileName)
xls = xlw.sheets(SheetNo)
For i = StartingRow To xls.Rows.Count
For j = StartingCol To MaxCol
If Trim(xls.Cells(i, StartingCol).Text) = "" Then
GetExcelToGrid = True
GoTo EndPart
End If
Dim _Value = Trim(xls.Cells(i, j).Text)
Next j
Next i
EndPart:
DGV.AllowUserToAddRows = False
xlw.close()
xla = Nothing
xlw = Nothing
xls = Nothing
If Not IsNothing(oldCI) Then System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
Catch ex As Exception
GoTo EndPart
End Try
No comments:
Post a Comment