# Removing empty rows from excel sheet or datatable

**URL:** <https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091>\
**Category:** Help\
**Created:** [September 20, 2018, 11:15am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091 "2018-09-20T11:15:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![supriyad](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supriyad/32/64572_2.png) [@supriyad](https://forum.uipath.com/u/supriyad)\
**Post date:** [September 20, 2018, 11:15am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/1 "2018-09-20T11:15:20Z")

</div>

hi can you tell me the simplest way that how to remove empty row from excel sheet ??  
i have implemented the below way but i want simplest way from below solution  
[abc.xlsx](https://global.discourse-cdn.com/uipath/original/3X/5/9/594f0c43ffc97f87424722b4d2125f7f9fdedcb2.xlsx) (11.4 KB)  
[Main.xaml](https://global.discourse-cdn.com/uipath/original/3X/d/d/ddc934d96dfb13af400b3a91709e862fae08a866.xaml) (16.1 KB)

---

<div class="post-metadata">

**Author:** ![akila93](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@akila93](https://forum.uipath.com/u/akila93)\
**Post date:** [September 20, 2018, 11:40am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/2 "2018-09-20T11:40:50Z")

</div>

Hi @supriyad,

Refer the below code to remove the empty row from the Data Table.

`DataTableName=DataTableName.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(""))).CopyToDataTable()`

Refer below link for more

> [@DataTable filtering with expressions](https://forum.uipath.com/t/datatable/21692):
>
> Hi All, Use below code to remove empty row from the table. DataTable name-\>DataTableName Use assign activity DataTableName=DataTableName.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(""))).CopyToDataTable() Re-usable Component pass Parameter as datatable you will get the answer. [RemoveEmptyRows.xaml](https://global.discourse-cdn.com/uipath/original/2X/1/18c0883a487d21d4e0c1031cfa692253af6718cf.xaml) (8.5 KB) Remove rows based on particular column is empty. DataTableName.Select("Convert(column3, System.String)\< \>''"…

---

<div class="post-metadata">

**Author:** ![indra](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/indra/32/34761_2.png) [@indra](https://forum.uipath.com/u/indra)\
**Post date:** [September 20, 2018, 12:05pm UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/3 "2018-09-20T12:05:42Z")

</div>

@supriyad Check attached file

[Main\_updated.xaml](https://global.discourse-cdn.com/uipath/original/3X/e/c/ecfff6c0bc4d22c9a98d17e09c5faa2bd4dd663c.xaml) (18.5 KB)

---

<div class="post-metadata">

**Author:** ![luchovelez](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/luchovelez/32/4453_2.png) [@luchovelez](https://forum.uipath.com/u/luchovelez)\
**Post date:** [September 29, 2018, 4:31pm UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/4 "2018-09-29T16:31:17Z")

</div>

use the new activity filter data table

---

<div class="post-metadata">

**Author:** ![Abhinavk8](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhinavk8](https://forum.uipath.com/u/Abhinavk8)\
**Post date:** [January 22, 2019, 9:01am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/5 "2019-01-22T09:01:54Z")

</div>

Hi Akila/Supriya,

There is no need of hard code to remove empty rows from excel sheet or dataTable.  
You can simply remove empty records using Filter DataTable activity.

Kindly refer the below image for reference. ![FilterDT](https://global.discourse-cdn.com/uipath/original/3X/9/1/9172049b1b64f4b52c1d636fb05c3a3ede22c153.png)

Regards,  
Abhinav:smiley:

---

<div class="post-metadata">

**Author:** ![apurba2samanta](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/apurba2samanta/32/80902_2.png) [@apurba2samanta](https://forum.uipath.com/u/apurba2samanta)\
**Post date:** [July 26, 2019, 12:58pm UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/6 "2019-07-26T12:58:55Z")

</div>

@supriyad According to your Excel file you can also check this.[Remove\_Empty\_rows.zip](https://forum.uipath.com/uploads/short-url/muReN35VGBsc5t9bhdUgmruOI4.zip) (31.4 KB)  
Thanks,  
Apurba

---

<div class="post-metadata">

**Author:** ![preetith](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@preetith](https://forum.uipath.com/u/preetith)\
**Post date:** [October 2, 2019, 4:20am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/7 "2019-10-02T04:20:46Z")

</div>

This helped me. Thanks !

---

<div class="post-metadata">

**Author:** ![apurba2samanta](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/apurba2samanta/32/80902_2.png) [@apurba2samanta](https://forum.uipath.com/u/apurba2samanta)\
**Post date:** [October 3, 2019, 2:50am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/8 "2019-10-03T02:50:07Z")

</div>

Hi @preetith,  
Most welcome dear. If you have got the solution, please mark the post, which you think your solution as **‘Solution’** and close the topic.

Thanks & Regards,  
Apurba

---

<div class="post-metadata">

**Author:** ![Aditya10989](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/aditya10989/32/263433_2.png) [@Aditya10989](https://forum.uipath.com/u/Aditya10989)\
**Post date:** [May 5, 2020, 6:28am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/9 "2020-05-05T06:28:39Z")

</div>

Hi I have same issue.Can we do this without using read range.because I have large data.Read range activity executing from last 6 hours.But did not got data in data table.I have 6,00,000 rows in excel.In which data contain only first 15,000 rows.So I want to delete rest of rows  
@Lahiru.Fernando

---

<div class="post-metadata">

**Author:** ![vikram.g1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vikram.g1/32/176675_2.png) [@vikram.g1](https://forum.uipath.com/u/vikram.g1)\
**Post date:** [October 1, 2020, 8:35am UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/10 "2020-10-01T08:35:13Z")

</div>

Hi @indra,

How can i handle if i need to delete both empty rows and columns in a excel, please can u suggest.  
Thanks,  
Vikram.G

---

<div class="post-metadata">

**Author:** ![Vijendar\_123](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vijendar_123/32/231746_2.png) [@Vijendar\_123](https://forum.uipath.com/u/Vijendar_123)\
**Post date:** [June 29, 2021, 5:57pm UTC](https://forum.uipath.com/t/removing-empty-rows-from-excel-sheet-or-datatable/66091/11 "2021-06-29T17:57:55Z")

</div>

Hi All,

You can use the below Linq query to delete rows which has empty cells in a datatable  
Use assign activity and assign the below query to a new Datatable.

**Datatable.AsEnumerable.where(Function(row) row.ItemArray.All(function(col) not string.IsNullOrEmpty(col.ToString))).CopyToDataTable**
