Write to Excel file using inputdlg for file name
古いコメントを表示
[EDIT: 20110603 09:29 CDT - reformat - WDR]
I am trying to write to an excel file that does not exist using xlswrite. The new excel file name will be an input from the user via the inputdlg command. My issue is, xlswrite is coming back with an error saying that it needs a string and what I am giving it is a cell. Here is my code:
prompt = {'Enter excel file name:'};
dlg_title = 'Excel File Name';
num_lines = 1;
def = {'DEMO1.xls'};
file_name = inputdlg(prompt,dlg_title,num_lines,def);
var1 = 10*rand(1,10);
xlswrite(file_name,var1,1,'A2')
% class(file_name)
%
% ans = cell
Thank you in advance for your help!
Eric
回答 (3 件)
Walter Roberson
2011 年 6 月 3 日
xlswrite(file_name{1},var1,1,'A2')
Titus Edelhofer
2011 年 6 月 3 日
Hi Eric,
inputdlg always returns a cell array, so:
xlswrite(file_name{1}, ...)
Titus
Fangjun Jiang
2011 年 6 月 3 日
0 投票
Based on your code, file_name is a cell array.
use xlswrite(file_anme{1},var1,1,'A2') instead.
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!