# Excel File question

**URL:** <https://forum.uipath.com/t/excel-file-question/754458>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, excel, activities\
**Created:** [July 18, 2024, 3:18am UTC](https://forum.uipath.com/t/excel-file-question/754458 "2024-07-18T03:18:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![A\_Learner](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/a_learner/32/181354_2.png) [@A\_Learner](https://forum.uipath.com/u/A_Learner)\
**Post date:** [July 18, 2024, 3:18am UTC](https://forum.uipath.com/t/excel-file-question/754458/1 "2024-07-18T03:18:35Z")

</div>

Hi,  
I am reading a downloaded excel file. The number of rows is dynamic.  
The Excel file has last row with totals. I have to eliminate this row before read range.  
How can I do that?

Thank you,

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [July 18, 2024, 3:20am UTC](https://forum.uipath.com/t/excel-file-question/754458/2 "2024-07-18T03:20:39Z")

</div>

Hi @A_Learner

→ Use the Read range workbook activity to read the excel and store in a datatable called Input\_dt.  
 → Then use the LINQ Exression to remove the last row from the datatable.

```auto
- Assign -> Input_dt = DT_True.AsEnumerable().SkipLast(1).CopyToDataTable()

```

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![A\_Learner](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/a_learner/32/181354_2.png) [@A\_Learner](https://forum.uipath.com/u/A_Learner)\
**Post date:** [July 18, 2024, 3:24am UTC](https://forum.uipath.com/t/excel-file-question/754458/3 "2024-07-18T03:24:56Z")

</div>

DT\_True same as input data table?

Thank you,

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [July 18, 2024, 3:25am UTC](https://forum.uipath.com/t/excel-file-question/754458/4 "2024-07-18T03:25:53Z")

</div>

Sorry @A_Learner

```auto
- Assign -> Input_dt = Input_dt.AsEnumerable().SkipLast(1).CopyToDataTable()

```

we are removing the last row of the datatable and storing into same datatable.

Hope you understand!!

---

<div class="post-metadata">

**Author:** ![A\_Learner](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/a_learner/32/181354_2.png) [@A\_Learner](https://forum.uipath.com/u/A_Learner)\
**Post date:** [July 18, 2024, 3:33am UTC](https://forum.uipath.com/t/excel-file-question/754458/5 "2024-07-18T03:33:19Z")

</div>

Thank you, it does not look like it is deleting the last row.  
I am doing write range into the same file into the sheet.  
Could it be that the previous value staying there?  
How do I delete that sheet and write again?

Thank you,

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [July 18, 2024, 3:43am UTC](https://forum.uipath.com/t/excel-file-question/754458/6 "2024-07-18T03:43:49Z")

</div>

You want to delete the last row in the excel file, If my understanding is correct.

Then follow the below steps,  
 → Use the Excel Process scope activity and insert the Use excel file activity inside of it.  
 → Give the Path of the Excel file to the Use excel file activity.  
 → Inside Use excel file activity insert the Find First\Last row activity to get the last row number.  
 → In the Source give Excel.Sheet(“Sheet name”),  
Check the Has headers option,  
Select the Last populated row option from the Configure last row dropdown and  
Create a variable in the Save row number as field, let’s call the variable as Lastrow.  
 → Then use the Delete rows activity to delete the Last row of the Excel.  
 → Give Excel.Sheet(“Sheet name”) in the In what table or range field and Select the Specific rows in the What to delete dropdown, and pass the Lastrow variable to the At Position field.

Check the below workflow for your better understanding,

 ![Sequence3](https://global.discourse-cdn.com/uipath/original/4X/e/3/2/e323e50de115aa5f95e5190664c948682b5a2ba7.jpeg)

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [July 21, 2024, 3:44am UTC](https://forum.uipath.com/t/excel-file-question/754458/7 "2024-07-21T03:44:38Z")

</div>

Closed on July 21, 2024, 3:44am UTC

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