How do I delete empty rows in StudioX?

I can’t use BalaReva excel activities because I’m using StudioX.

Do you have any ideas how can I handle this?

I want to delete empty rows so this is what I have:


And I need:

How else can I handle it?

Hi @anon40731888
Try this in assign activity

ExcelData.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(“”))).CopyToDataTable()

I hope it helps

I don’t understand this I’m using StudioX:(

In accordance of Studio X limitations:

  1. Drag and drop the “Read Range” activity to read the data from your Excel file. Configure it to read the range of cells that contain your data.
  2. Add an “Assign” activity to create a new variable called filteredData of type System.Data.DataTable. Set its initial value to DataTable.Clone() to create an empty copy of the original table structure.
  3. Add a “For Each Row” activity to iterate over each row in the DataTable obtained from the “Read Range” activity.
  4. Inside the “For Each Row” activity, add an “If” activity to check if the row is empty. You can use the condition String.IsNullOrWhiteSpace(row.ItemArray().ToString).
  5. If the row is not empty, add an “Add Data Row” activity below the “If” activity to add the non-empty row to the filteredData DataTable.
  6. After the “For Each Row” activity, add a “Write Range” activity to write the filteredData DataTable to the Excel file, replacing the existing data. Configure the activity to write to the same range as the original “Read Range” activity.

Thank you but it was easier than that, I got advised to just filter my sheet, and then use delete rows activity. It worked.

1 Like

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