# Split excel files into multiple files

**URL:** <https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376>\
**Category:** Automation Hub\
**Tags:** excel, system, activities\
**Created:** [March 3, 2021, 6:48pm UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376 "2021-03-03T18:48:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 3, 2021, 6:48pm UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/1 "2021-03-03T18:48:56Z")

</div>

Hi all,

Scenario: Read the file and store it in data table, next take total count of rows and divide it by a number which is configurable (3,4,5,6,7…).  
Next based on divided value obtained it has create multiple excel files

Eg: If total count is 31 and in config file the no provided is 5,so it has to create 5 files with count of rows in excels files as 6+6+6+6+7  
Similarly if total count is 30 and in config file the no provided is 3,it has to create 3 files with count of rows in excel files as 10+10+10.  
Please can of you help me out on this.

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [March 3, 2021, 6:52pm UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/2 "2021-03-03T18:52:41Z")

</div>

@Deeksha_Devaiah  
have a look here:

> [@Split Datatable into 4 different tables](https://forum.uipath.com/t/split-datatable-into-4-different-tables/284608/4):
>
> @thomasb82 lets assume following variables: NoOfSegments is indicating how many splits we do want have Doing an integer division to find out how many rows will be in a split (we cannot fetch a rows count with fractions e.g. 14.25 rows [grafik] with following LINQ we can produce a list of datatables with the splits: [grafik] (From i In Enumerable.Range(0,NoOfSegments) Let opart = dtData.AsEnumerable.Skip(i\*FullSegmentSize).toList Let spart = If(i = (NoOfSegments - 1), opart, opa…

> [@Split excel files if they exceed 500 rows](https://forum.uipath.com/t/split-excel-files-if-they-exceed-500-rows/267478/3):
>
> @RoboBob find starter help here: [DTSlice\_BySegmentSize\_ToTableList.xaml](https://forum.uipath.com/uploads/short-url/5bGp7hoQaGAIQSmmRXKGqkc7eLP.xaml) (10.5 KB) Explanation of the concept you can find here:

---

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 4, 2021, 3:08am UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/3 "2021-03-04T03:08:34Z")

</div>

Thanks Peter.  
Will look into it,if any doubts on this will get back to you.

---

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 4, 2021, 8:10am UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/4 "2021-03-04T08:10:07Z")

</div>

Any other solution please?

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [March 4, 2021, 8:37am UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/5 "2021-03-04T08:37:05Z")

</div>

@Deeksha_Devaiah Can you tell us what kind of Solution are you looking into ?

---

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 4, 2021, 8:52am UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/6 "2021-03-04T08:52:57Z")

</div>

Hi Arpan,

As per the scenario,the total count of rows will depend on the excel provided by business and I divide it by either 3,4,5 or any no which is configurable  
As in solution suppose the excel count is 31 and it is divided by 5 so which will be a decimal value 6.2. So the bot has to spilt those 31 rows into 5 excels each having 6 rows and one with 7 rows …If suppose the total row count is 500 and divided value is 10 then we need to have 50 rows in each excel.so both scenarios code has to work.

---

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 4, 2021, 12:29pm UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/7 "2021-03-04T12:29:58Z")

</div>

Is there a way ?

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [March 4, 2021, 1:34pm UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/8 "2021-03-04T13:34:08Z")

</div>

@Deeksha_Devaiah Check the below workflow :  
[Split Excel Rows into Different Excel.zip](https://forum.uipath.com/uploads/short-url/ArUoF6cnuyT2AXee2egGs8bBdzX.zip) (15.8 KB)

Check the Input Excel File. Execute the Workflow. The Output files will be generated in the Output folder.

This is a similar operation as to what is done in the above posts. But if you are not convinced with this method of execution to attain the required output then I suggest you to explain in a little more detail as to why the Solution is not the Expected one.

Also Test the Workflow with different inputs and revert back if it didn’t help.

---

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 4, 2021, 4:33pm UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/9 "2021-03-04T16:33:25Z")

</div>

@supermanPunch  
Yea it is working fine…Please can you give a brief explanation on the code part it would be helpful,i understood but not that clear…What does that in for each loop having enumerable mean?

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [March 5, 2021, 4:50am UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/10 "2021-03-05T04:50:02Z")

</div>

@Deeksha_Devaiah Check the below link for more clear explanation on the Enumerable methods :

> **[C# Enumerable.Range, Repeat and Empty - Dot Net Perls](https://www.dotnetperls.com/enumerable-range)**
>
> Use the Range method on the Enumerable type to get a range of numbers. Invoke Repeat and Empty.

---

<div class="post-metadata">

**Author:** ![Deeksha\_Devaiah](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/deeksha_devaiah/32/180746_2.png) [@Deeksha\_Devaiah](https://forum.uipath.com/u/Deeksha_Devaiah)\
**Post date:** [March 5, 2021, 9:32am UTC](https://forum.uipath.com/t/split-excel-files-into-multiple-files/295376/11 "2021-03-05T09:32:36Z")

</div>

@supermanPunch  
Thanks much.
