フィルターのクリア

I have 10 excel files, i want the name of each excel file.

2 ビュー (過去 30 日間)
Mohammad Abu Zafer Siddik
Mohammad Abu Zafer Siddik 2016 年 11 月 20 日
コメント済み: Walter Roberson 2016 年 11 月 20 日
I have 10 excel files, i want the name of each excel file.
Thanks in advance

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 11 月 20 日
%code to find all excel files in a directory
%warning: this code makes no attempt to verify that xml files were produced by Excel
excel_extn = {'xlc', 'xls', 'xlsb', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'xlw', 'xml' };
projectdir = 'C:\Where\Your\Files\Are';
num_extn = length(excel_extn);
dinfo = cell(num_extn, 1);
for K = 1 : num_extn
dinfo{K} = dir( fullfile( projectdir, ['*.', excel_extn{K}]);
end
dinfo = vertcat(dinfo{:});
excel_file_names = fullfile( projectdir, {dinfo.name} );
In the special case where only a single excel extension is to be handled, this code could be much shorter.
  3 件のコメント
Mohammad Abu Zafer Siddik
Mohammad Abu Zafer Siddik 2016 年 11 月 20 日
I have only xls files. 'excel_file_names' does not have anything.
Walter Roberson
Walter Roberson 2016 年 11 月 20 日
projectdir = 'C:\Where\Your\Files\Are';
dinfo = dir( fullfile(projectdir, '*.xls') );
excel_file_names = {dinfo.name};
Be sure to update projectdir to the appropriate directory name.
In the case of wanting to find the files in the current directory:
dinfo = dir( '*.xls' );
excel_file_names = {dinfo.name};
You can cross-check with
ls('*.xls')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by