Hello,
How i can detect from the excel rows if i have missed information added in some cell.
Examples i have excel file with information columns A, B, C and for example i want to check if there is missing added text in rows in C column.
Not to detect other empty rows that excel has after the last record and to display it in DataGridView the rows that have missing information added A, B, C
Using workBook As XLWorkbook = New XLWorkbook(TxtPathLocation.Text + "\Production modules.xlsx")
Dim workSheet As IXLWorksheet = workBook.Worksheet(1)
Dim dt As DataTable = New DataTable()
Dim firstRow As Boolean = True
For Each row As IXLRow In workSheet.Rows()
If firstRow Then
For Each cell As IXLCell In row.Cells()
dt.Columns.Add(cell.Value.ToString())
Next
firstRow = False
Else
Dim cellA As IXLCell = row.Cell(1)
Dim cellB As IXLCell = row.Cell(2)
Dim cellC As IXLCell = row.Cell(21)
Dim isLowerLetter As Boolean = False
If cellB.Value.ToString().Any(AddressOf Char.IsLower) Then
isLowerLetter = True
End If
If isLowerLetter Then
DataGridView2.Rows.Add(cellC.Value.ToString(), "Production Modules", "", cellB.Value.ToString(), "Found issue with lower text in Production Names")
End If
End If
Next
dt.Columns.RemoveAt(0)
DataGridView2.Rows.Add(dt)
firstRow = True
Dim lastrow As Integer = workSheet.LastRowUsed().RowNumber()
Dim rows = workSheet.Rows(1, lastrow)
For Each row As IXLRow In rows
If firstRow Then
For Each cell As IXLCell In row.Cells()
If cell Is Nothing Then
dt.Columns.Add(cell.Value.ToString())
End If
Next
firstRow = False
Else
Dim cellA As IXLCell = row.Cell(1)
Dim cellB As IXLCell = row.Cell(2)
Dim cellC As IXLCell = row.Cell(21)
Dim isLowerLetter As Boolean = False
If cellC.Value Is Nothing Then
isLowerLetter = True
End If
If isLowerLetter Then
DataGridView2.Rows.Add(cellC.Value.ToString(), "Production Modules", "", cellB.Value.ToString(), "Found Missing Workcenter")
End If
End If
Next
dt.Columns.RemoveAt(0)
DataGridView2.Rows.Add(dt)
End Using
I had added in combined in the previous code + this option now to be inside in 1 code both. But it doesn’t detect me the empty cell.
Let's say the row has column B with text but C is empty on that line row.
And another thing i notice is that when i combine them in datagridview2 has 1 empty row added then show result after that for the second code. Can it be straight 1 after another result in DataGridView without add separator 1 empty row?