The Source Data has no Rows or Columns

So my activity is where I have a column in excel which contain links and when opened each of those links the page contains data tables which I would like to extract and past it in another sheet. I open each link using “for each row in datatable” and it works fine.

However, sometimes some of these links when opened on website might not contain tables and might be empty. during this time, it throws error

Source: WriteDataTable to Excel

Message: The source Data has no rows or columns.

Exception type: UiPath.Excel.ExcelException

Attached one screenshot. What I need is for this to skip that link when this error occurs and the loop continues to the new rows/of links in excel.

I think try catch might help here however, I am not sure how to use it, could you please help, I have attached few screenshots

I added another attachment of how I think try and catch might help but not sure where to add and how to write an if to it

Yes, using a Try-Catch block in UiPath can be a good approach to handle errors that might occur during the execution of your automation.

Here’s how you can use a Try-Catch block to handle the error you are facing:

  1. Add a Try-Catch activity to your workflow, with the activities that read and write the data tables inside the Try block.
  2. Inside the Try block, add a nested If activity to check if the data table is empty before writing it to the other sheet. You can use the DataTable.Rows.Count property to check the number of rows in the table.
  3. If the table is not empty, write it to the other sheet as you are currently doing.
  4. If the table is empty, use a Throw activity to throw a new exception. This will cause the workflow to jump to the Catch block.
  5. Inside the Catch block, add a Log Message activity to log the error message, and another Throw activity to re-throw the same exception. This will cause the workflow to exit the Try-Catch block and continue with the next link in the loop.
1 Like

@girishankar09

You can actually use this if consition as a proactive measure rather than try catch…

Use this in if condition

IsNothing(var3) OrElse var3.RowCount.Equals(0)

On else side use write range and leave the then side empty

Hope this helps

Cheers

Hey @Nitya1 , Thanks for the prompt response, really appreciate the help. Quick question,

I am using throw twice

  1. (4. If the table is empty, use a Throw activity to throw a new exception. This will cause the workflow to jump to the Catch block.). Here is what I did is:
    Step 1 If- condition- “DataTable.Rows.Count <> 0”
    Step 2 Under Then- I added the write to excel activity
    Step 3 Under Else- “I added Throw activity”

  2. (5. Inside the Catch block, add a Log Message activity to log the error message, and another Throw activity to re-throw the same exception.). Here is what I did

Step 1 Under Catches I selected ExcelException under exception, added log message action under which I selected ‘Error’ from dropdown and under the message I wrote “Skip the step”+exception.tostring"
Step 3 Added another Throw activity just below the Log Message activity

My question is, what do I add or write under both these


throw activity?

Hi @girishankar09 ,

You can use rethrow activity instead of throw activity, if you want the same exception to be thrown.

Regards,

1 Like

Hi

If you want to process next item from the beginning of the loop when exception occurs, can you try Continue activity as the following?

Regards,

1 Like

Thanks @Anil_G This was really simple and worked perfectly.

1 Like

Thanks everyone for your help…

1 Like

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