필터 지우기
필터 지우기

How can I print names of files or folders contained in a specific folder in first row in excel sheet?

조회 수: 3 (최근 30일)
For example, if there are 10 folders in a directory, how can I print their names in the first excel row, with the format '1 name for each cell'?
Here is the code of what I tried so far
for folder = 1:length(srcFolders)
path = strcat('D:\',srcFolders(folder).name);
folder_range = strcat(column_range, '1');
xlswrite(xls_filename, {srcFolders(folder).name}, xls_sheet, folder_range);
end
  댓글 수: 1
ahmed obaid
ahmed obaid 2015년 7월 16일
thank you sir its working well , only small note if i need to print these names in first column A in excel file , when i have to change arguments or code portion ,,, thanks again

댓글을 달려면 로그인하십시오.

채택된 답변

Shiran Golan
Shiran Golan 2015년 7월 14일
this should work:
srcFolders = dir;
for folder = 1:length(srcFolders)
srcFolders(folder).fullname = strcat('D:\',srcFolders(folder).name);
end
xlswrite('xlsFile', {srcFolders(:).fullname}, 'xlsSheet','A1');
Notice that the writing to excel file is only the last row, and the loop only adds the prefix of the path into a new field in the directories struct

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by