matlab读取sheet1_matlab读取多个excel并输出

matlab代码如下:

clear;

clc;

filePath=uigetdir({},'choose your filepath'); %获取excel文件存储目录

getFileName=ls(strcat(filePath,'\*.xl*'));  %获取所选目录下的文件名

fileName = cellstr(getFileName); %将string数组转为cell数组

if  isequal(getFileName,'')%防止选择空文件夹

msgbox('no excel file in the path you selected');

else

mkdir(strcat(filePath,'\output'));%新建输出文件夹

waiting=waitbar(0,'excuting...,please wait!');%进度条

for i=1: length(fileName)                                                  %foreach your files

[excelData,str] = xlsread(strcat(filePath,'\',fileName{i}));%读取excel

xlswrite(strcat(filePath,'\output\output.xlsx'),str,strcat('Sheet',num2str(i)), 'A1');%将读取的工作表表头写入excel

xlswrite(strcat(filePath,'\output\output.xlsx'),excelData,strcat('Sheet',num2str(i)), 'A2');%将读取的工作表数字写入excel

end

close(waiting)%关闭进度条

disp 'you can find output file there:'

outputPath = strcat(filePath,'\output\output.xlsx')

msgbox(strcat('finished,get output file in:',outputPath),'Success','Help');%prompt message

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值