I have an excel file which consists of a table which is unstructured and I’m trying to extract the value from last non empty cell of each row. I tried using Get Row Item activity with column index as finalDT.Columns.Count - 1 in For each row, but this returns empty values as well. Any help would be appreciated. Please find the attached excel file (Sheet 2).
hi @Sripadraj, Try to read the excel file first and get the row count from it so that you can able to know the last cell value. by that you can fetch last non empty value from the cell.
@Sripadraj
It would be easier to get it from Sheet1, before it’s split:
foreach (row in dt)
{
string lastCell = row(0).ToString().Split(","c).Last()
}
@ranjith
Probably you could, but I don’t think it’s worth the trouble.
It’s clearer to just use a normal loop.
That said: row(col) is nothing or row(col).Equals("")
There’s a better way to test for null or empty: String.IsNullOrEmpty(row(col))
Another thing is that or operator tests both sides, which means that if your second check involves a method call and the object is null, it will still throw a null reference. Use OrElse in these situations.
See here for more info.
Use for each row activity to iterate every row in a datatable and fetch the column value either by passing its column index or column name like row(column_index) or row(“column_name”).
Getting this error in getting data from rows, i tried fetching the row index as well,
its throwing an exception when i tried using Get Row Item as column dont belong to the table, though column name is perfectly added
i’m a beginner, please help in fixing,