# Merge two excel file with multiple sheet into one file

**URL:** <https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733>\
**Category:** KNIME Extensions\
**Tags:** batch, database, excel, bug\
**Created:** [June 2, 2022, 6:20pm UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733 "2022-06-02T18:20:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksurendra](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@ksurendra](https://forum.knime.com/u/ksurendra)\
**Post date:** [June 2, 2022, 6:20pm UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733/1 "2022-06-02T18:20:21Z")

</div>

I have two excel file with four sheet each and I want to make one excel file by combining given two excel file and form file of eight sheet .  
I tried to solve by referring previous solution but that didn’t help. Please anyone can help me in this problem statement.

---

<div class="post-metadata">

**Author:** ![bruno29a](https://forum-cdn.knime.com/user_avatar/forum.knime.com/bruno29a/32/28802_2.png) [@bruno29a](https://forum.knime.com/u/bruno29a)\
**Post date:** [June 3, 2022, 5:09am UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733/2 "2022-06-03T05:09:37Z")

</div>

Hi @ksurendra and welcome to the Knime Community.

Can you tell us what is the previous solution you are referring to and what you have tried so far?

The general solution is to read each sheet and write them to a different sheet but of the same destination excel file.

For example, let’s say the 2 files are file\_1.xls and file\_2.xls, and let’s say the combined file is final\_file.xls

You will read each sheet from file\_1.xls and write to a new sheet in final\_file.xls. Similarly with file\_2.xls, you read each sheet and write to a new sheet in final\_file.xls.

The specifics of the solution will depend on a few things, such as do you want to use new names for the sheets in final\_file.xls, or do you want to use the original names of the sheets? And if you wanted to use the same original names, what if there are duplicated sheet names (that is some sheets from file\_1.xls have the same names from file\_2.xls)?

I put something simple together, and I chose to generate new generic names for the new sheets in case you need this - you can skip that part if you don’t need it.

The workflow looks like this:  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/1/2/1274680f1b47b06df1c997daeaeed555d810b9bf.png)

I purposely used 2 similar processes in the workflow, 1 for each file so that it is not too confusing (the second one is copied from the first one, and simply points to file\_2.xlsx instead of file\_1.xlsx). This can of course be replaced by a loop (so you’d end up with a nested loop)

file\_1.xlsx and file\_2.xlsx are similar in that they each have 4 sheets, and there’s only 1 cell in each of the sheets, where file\_1.xlsx has 1-4 incrementing in the sheets, and file\_2.xlsx has 4-8 incrementing in the sheets.

file\_1.xlsx:  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/3/53ae0ee3cee7c9a7921437dd1c5141c4678beee1.png)  
…  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/f/ef00aa3f3d3fb0cde474502195277d5f11ad5521.png)

file\_2.xlsx:  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/e/5e358e6c0e2128865d399853e7755228b5a66df7.png)  
…  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/7/e/7ecdbbf3fa12a12b06dfffe3b2b3d17fc9383f4d.png)

Results:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/d/9d62b8c616fb7d9ad39a133847adc983f6fcc0c4.png)  
…  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/e/be6d79515d613dc08bdd130a6b8da9d6dc21658d.png)  
…  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/b/bbdeecea3b1b321d33147eb630d05b6c20bc7772.png)

Here’s the workflow:

> **[Merge two excel file with multiple sheet into one file – bruno29a](https://hub.knime.com/bruno29a/spaces/Public/latest/Forum/Merge%20two%20excel%20file%20with%20multiple%20sheet%20into%20one%20file~sfo2mbXQUVCSsuhB)**
>
> This is in relation to:

---

<div class="post-metadata">

**Author:** ![ksurendra](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@ksurendra](https://forum.knime.com/u/ksurendra)\
**Post date:** [June 3, 2022, 7:11am UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733/3 "2022-06-03T07:11:15Z")

</div>

Thanks @bruno29a for your solution. it almost solve my problem, it has one error that in first four sheet value are same and in last four sheet value are same. Like in first four sheet I got 1 and last four sheet I got 5.

---

<div class="post-metadata">

**Author:** ![bruno29a](https://forum-cdn.knime.com/user_avatar/forum.knime.com/bruno29a/32/28802_2.png) [@bruno29a](https://forum.knime.com/u/bruno29a)\
**Post date:** [June 3, 2022, 12:22pm UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733/4 "2022-06-03T12:22:35Z")

</div>

Hi @ksurendra , I’m not sure what you did on your side, but you can clearly see in the screenshots of my results that the values are different - that’s why I showed the first sheet, one in the middle and the last one.

I just re-ran the workflow again to double check. Here’s the generated file by the workflow:  
[final\_file.xlsx](https://forum.knime.com/uploads/short-url/cZPpl84ntWoUhVp6rFAROKShFXQ.xlsx) (6.3 KB)

And here’s the content of the file:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/5/65b6a5bb6031688e7ccb2fd9a0290f2a9878d952.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/4/4/44d276c86243d5470764b6cf3875941c4ae23322.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/8/5/85c9f9737495ca100bc5ce0aad2fcd00834c88fe.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/9/390420685c587bf2bdd1302e6c8535ae93c56472.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/d/fd6ac01b4e83a98d79c94acd48bcc17dfa788461.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/f/e/fe53485acd888132f0603ea772c3f5c518deb996.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/6/a/6a069e1f7d110aa0a1e1493dbd1b1949f4e5977d.png)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/8/b83016938c0515f07d7e9d50cb64b22ec6cd2d46.png)

Each of the new sheets captured the content of the different sheets from the original files.

---

<div class="post-metadata">

**Author:** ![ksurendra](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/k/8dc957/32.png) [@ksurendra](https://forum.knime.com/u/ksurendra)\
**Post date:** [June 6, 2022, 1:04pm UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733/5 "2022-06-06T13:04:11Z")

</div>

I think there is some fault from my side and thanks @bruno29a for helping

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [September 4, 2022, 1:04pm UTC](https://forum.knime.com/t/merge-two-excel-file-with-multiple-sheet-into-one-file/43733/6 "2022-09-04T13:04:54Z")

</div>

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