merging excel files

2 views (last 30 days)
Riti kushwaha
Riti kushwaha on 7 Nov 2011
Edited: Shuba Nandini on 24 Dec 2024
hey can u please tell me how to make one excel file by merging more then one excel files one after another. if u are having any solution please tell me. thenx in advance....
  2 Comments
Fangjun Jiang
Fangjun Jiang on 7 Nov 2011
It can be done but you'll need to provide more details. Do original files contain multiple sheets? How do you want to merge, to one sheet or multiple sheets? What are the size of the original data? Are they all the same or different? How do you merge them, vertical or horizontal?
Titus Edelhofer
Titus Edelhofer on 7 Nov 2011
Generally speaking: yes, using xlsread and xlswrite and usual methods for merging data (concatenation, interpolation)...

Sign in to comment.

Answers (1)

Shuba Nandini
Shuba Nandini on 24 Dec 2024
Edited: Shuba Nandini on 24 Dec 2024
Hi,
To merge multiple Excel files into a single file using MATLAB, you can utilize functions such as xlsread and xlswrite for basic data handling as Titus suggested.
Kindly refer to the following workarounds to merge excel files in MATLAB:
  • Merging Two Excel files using "xlsread" and "xlswrite": The xlsread function reads data from an Excel file, and xlswrite writes data to an Excel file.
Kindly refer to the following sample code snippet to merge two excel files:
data1 = xlsread('file1.xlsx'); % Load data from file 1
data2 = xlsread('file2.xlsx'); % Load data from file 2
data3 = [data1; data2]; % Create data for file 3
xlswrite('file3.xlsx', data3); % Create file 3
  • Merging Multiple Excel Files using "readtable" and "writetable":
  1. Create an empty table named combinedData to store the concatenated table data.
  2. Loop through each Excel file, and use the readtable function to read the spreadsheet data into a table, appending it to combinedData.
  3. After the loop, write the combinedData table into a new Excel file using the writetable function.
For more information on the second workaround, please refer to the following MATLAB Answer:
I hope this helps!

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!