Read workbook but do not write to application when column is empty

Hello, I am fairly new to UiPath but experimenting with a solution that reads multiple cell values from a workbook and writes the values to an application. I have already built a solution that is able to do that if all the cells of the excel workbook are populated. But as soon as the code comes across a blank cell with no value/null value the solution breaks and does not continue further.

I looking for a way that does not throw error when it encounters an empty cell.
I need something that will let read the excel workbook and write the values from cells in an application, but if it comes across an empty cell it will skip that writing process and go onto the next cell.

I tried enabling continue on error through the activities property window but that’s not an ideal solution. I would really appreciate any feedback from the community on this topic.

Thanks!

Hi @abhishek.singh4

In for each row in datatable activity take an if condition in that

NotString.IsNullOrEmpty(CurrentRow(“YourColumnName”).ToString)

Hi @abhishek.singh4

Inside the For Each Row loop, use an If activity to check if a specific cell in the row is empty or null. You can use the String.IsNullOrWhiteSpace function to check for empty or whitespace-only values.

If Not String.IsNullOrWhiteSpace(row("Column1").ToString)
Then continue the process

HI @abhishek.singh4

Can you check whether do you have value in the Input sheet?

  1. Use read range activity → Store it in the DtInputy
  2. Use For each row in data table activity
  3. Use If activity
If Not String.IsNullOrWhiteSpace(row("Columnname").ToString)

Then-> Use Type into activity

Indicate the element in the application

Currentrow("Columnname').tostring.Trim

@abhishek.singh4

If you have more number of columns, it might be hard to check every column cell then try this approach:

<For Each dt> (Loop through the DataTable)
    <For Each dt.Columns> (Loop through all the columns in the row) 
        <Assign Activity> (Assign the current cell value to a variable)
        <If Activity> (Check if the cell is not empty or not null)
            Condition: Not String.IsNullOrWhiteSpace(cellValue.ToString)
            Then:
                <Write to Application> (Write the cell value to the application)

Hope it helps.

Hi @abhishek.singh4 ,

Could you let us know what is used for Reading the Excel sheet or Cell ? We might be able to perform the correction in your code itself if there is minor correction to be done.

Let us know what is the implementation done from your end to help further and if possible try to correct the existing implementation.

Hi Lakshman,

Thanks for providing with an example. I tried your method but the code is skipping entire row instead of just the empty column. For reference there are multiple columns but if there are values in one of the columns then we need to write the values from that column to the application but if in the same row if there is an empty cell, we just need to skip that cell and carry on with the rest of the cells.

Hi Gokul,

Thanks for the reply. I tried your suggested method but the code is skipping entire row instead of just the empty column. For reference there are multiple columns but if there are values in one of the columns then we need to write the values from that column to the application but if in the same row if there is an empty cell, we just need to skip that cell and carry on with the rest of the cells.

Hi Supriya,

Thanks for the reply. Your right, there are multiple columns. For reference there are multiple columns but if there are values in one of the columns then we need to write the values from that column to the application but if in the same row if there is an empty cell, we just need to skip that cell and carry on with the rest of the cells.

Do you provide me a screenshot of the tool used to write the above code, and is that code still valid for the scenario I descried.

@abhishek.singh4

Try like this

Not CurrentRow.ItemArray.Any(Function(cell) String.IsNullOrWhiteSpace(cell.ToString()))

@abhishek.singh4

I have uploaded the workflow. Analyze the workflow then you got the point. Ping me if any queries.
Sequence11.xaml (22.5 KB)

Note : Please change the count value to 1 in the assign activity. I forgot to change the value.

Can you share the sample input file? @abhishek.singh4

Hi Supriya,

Thanks that worked!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.