# Table Extraction- Write DataTable to Excel Error

**URL:** <https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259>\
**Category:** Studio\
**Tags:** table-extraction, data-scraping, data-extraction, excel, uiautomation, activities\
**Created:** [August 12, 2023, 2:20am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259 "2023-08-12T02:20:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heydi\_Reyes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/heydi_reyes/32/419768_2.png) [@Heydi\_Reyes](https://forum.uipath.com/u/Heydi_Reyes)\
**Post date:** [August 12, 2023, 2:20am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/1 "2023-08-12T02:20:06Z")

</div>

Hello,

I’m trying to look up the employee number of a list of companies (list is in excel), and trying to extract the number and write it into a new column on the excel document. I keep receiving the following error: **Write DataTable to Excel: The source data has no rows or columns.** I have included screenshots of my sequence. Any help would be greatly appreciated!!

 ![UiPath1](https://global.discourse-cdn.com/uipath/original/4X/f/2/8/f285a3d35aae72fa21ac7af53bcc40a3ee27a0e9.png)

---

<div class="post-metadata">

**Author:** ![Heydi\_Reyes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/heydi_reyes/32/419768_2.png) [@Heydi\_Reyes](https://forum.uipath.com/u/Heydi_Reyes)\
**Post date:** [August 12, 2023, 2:20am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/2 "2023-08-12T02:20:39Z")

</div>

rest of the sequence

 ![UiPath2](https://global.discourse-cdn.com/uipath/original/4X/b/9/9/b99c4c6a81c1f78e50508d2b857c4f0357d9d2e2.png)

---

<div class="post-metadata">

**Author:** ![Heydi\_Reyes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/heydi_reyes/32/419768_2.png) [@Heydi\_Reyes](https://forum.uipath.com/u/Heydi_Reyes)\
**Post date:** [August 12, 2023, 2:21am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/3 "2023-08-12T02:21:12Z")

</div>

Lastly.

 ![UiPath3](https://global.discourse-cdn.com/uipath/original/4X/5/e/8/5e8810a960f9f073e3ebdd3872ac1ceacb90d70d.png)

---

<div class="post-metadata">

**Author:** ![Parvathy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/parvathy/32/484539_2.png) [@Parvathy](https://forum.uipath.com/u/Parvathy)\
**Post date:** [August 12, 2023, 2:32am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/4 "2023-08-12T02:32:20Z")

</div>

Hi @Heydi_Reyes

Before writing the data table to excel check if the table is getting extracted .  
Keep a message box after Extract Table Data activity and verify if the count is equal to the table extracted by below condition:  
`ExtractDataTable.Rows.Count`  
If the row count is 0 then your table isn’t getting extracted.

Check and update.

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [August 12, 2023, 2:35am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/5 "2023-08-12T02:35:56Z")

</div>

In the Extract wizard, what do you see when you click Preview?

Obviously the datatable isn’t being populated so you have to figure out why.

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [August 12, 2023, 3:33am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/6 "2023-08-12T03:33:17Z")

</div>

HI @Heydi_Reyes  
Welcome to community

1.try to check the value of extracteddatatable  
Place a message box orl og message and  
Check extracteddatatable.rows.count

2.can please place the write range workbook activity outside of for each row in datatable

Hope this helps

---

<div class="post-metadata">

**Author:** ![rlgandu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rlgandu/32/488436_2.png) [@rlgandu](https://forum.uipath.com/u/rlgandu)\
**Post date:** [August 12, 2023, 4:48am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/7 "2023-08-12T04:48:39Z")

</div>

@Heydi_Reyes

 ![image](https://global.discourse-cdn.com/uipath/original/4X/c/b/b/cbb51c29906da3e37c6f8da9b267356a6682ff6d.png)

Here you take read range activity does not give any datatable variable

Instead of for each excel row you read the data to the datatable right then take for each row in datatable

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [August 12, 2023, 5:47am UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/8 "2023-08-12T05:47:56Z")

</div>

@Heydi_Reyes

Few things

1. In read range no datatable is provided that is not needed at all for each row in excel will take care of going through each row
2. In the typing to you can directly use `currentRow.ByIndex(0).StringValue`
3. In write range you can specify only the start cell and it would write all the data `Excel.Sheet("SheetNams").Range("B2")`
4. Looks like data is not getting populated in the extract datatable…either selector is not dynamic or wrong or there is no data

Cheers

---

<div class="post-metadata">

**Author:** ![Heydi\_Reyes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/heydi_reyes/32/419768_2.png) [@Heydi\_Reyes](https://forum.uipath.com/u/Heydi_Reyes)\
**Post date:** [August 14, 2023, 5:46pm UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/10 "2023-08-14T17:46:54Z")

</div>

Hi Anil,

Thank you so much for the feedback! Please see my questions below:

1. Where should I insert the following information? In the For Each Excel Row table or the Write DataTable to excel table? Sorry i’m very new to RPA so the more detail you can provide the better.

Thank you!

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [August 14, 2023, 6:02pm UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/11 "2023-08-14T18:02:07Z")

</div>

@Heydi_Reyes

Can you provide the value in the read range

---

<div class="post-metadata">

**Author:** ![Heydi\_Reyes](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/heydi_reyes/32/419768_2.png) [@Heydi\_Reyes](https://forum.uipath.com/u/Heydi_Reyes)\
**Post date:** [August 14, 2023, 6:08pm UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/12 "2023-08-14T18:08:34Z")

</div>

Hi Shiva,

The value in the read range is the company name “Google”

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [August 14, 2023, 6:11pm UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/13 "2023-08-14T18:11:52Z")

</div>

You are using for each excel row  
Before that you need to  
Create a variable for the output of read range excel

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [August 14, 2023, 8:19pm UTC](https://forum.uipath.com/t/table-extraction-write-datatable-to-excel-error/572259/14 "2023-08-14T20:19:49Z")

</div>

@Heydi_Reyes

> [@Anil\_G](#):
>
> currentRow.ByIndex(0).StringValue

This is to be used in type into activity

> [@Anil\_G](#):
>
> Excel.Sheet(“SheetNams”).Range(“B2”)

In the destination field of write datatable to excel activity

And read range can be removed

Hope this helps

Cheers
