Delete empty rows from an excel file without using excel activities

Hello!

I need your help please.

I have an excel file from which I need to delete the blank lines. For example, from A11 to A19, but without using the specific Excel activities, because I don’t have Excel installed on the computer where the robot will run…

After deleting the lines, the existing formulas from columns J to N must remain written as formulas (I have formulas on columns J-N and I don’t want to be deleted).

Any ideas how I could do this?

Thank you,

Hi @LZlz

Yes, there is a way to achieve this using UiPath. You can use the following steps:

  1. Read the Excel file using the “Read Range” activity and store the data in a DataTable variable.
  2. Iterate through each row of the DataTable using a “For Each Row” activity.
  3. Check if the row is blank by checking if all the columns in the row are empty. You can use the following condition: row.ItemArray.All(Function(x) String.IsNullOrEmpty(x.ToString.Trim)).
  4. If the row is not blank, copy the row to a new DataTable variable using the “Add Data Row” activity.
  5. After iterating through all the rows, write the new DataTable variable to a new Excel file using the “Write Range” activity.

To preserve the formulas in columns J-N, you can select those columns before deleting the blank rows and then copy and paste the formulas back into those columns after deleting the blank rows

Thank you, I will try today your method :slight_smile:

1 Like

Hi @LZlz

Did it worked for you?

Hi Nitya,

Sorry for the delayed response. I was on an Easter vacation. It was not necessary to test your suggestion anymore because in the meantime, the logic for creating the Excel file has been modified so that it no longer displays those partially completed rows.

Your suggestion may work, but I do not have the time to test it. Perhaps other colleagues on the forum who are in the same situation will be able to do so.

Thank you again :pray: :hugs: