フィルターのクリア

How to save a certain excel file to a specific folder?

8 ビュー (過去 30 日間)
Bryant
Bryant 2014 年 7 月 2 日
コメント済み: Bryant 2014 年 7 月 2 日
Does anyone know how to save an excel file that was already written to a certain folder? I want the excel file I save using xlswrite to save in my Dropbox folder for reference.
name_xls = input('What do you want to name the Excel file as?' , 's');
xlswrite(name_xls, exceloutput, '90CtT 45W','A1');

採用された回答

Uladzimir
Uladzimir 2014 年 7 月 2 日
編集済み: Uladzimir 2014 年 7 月 2 日
you can do it with the standard uiputfile dialog, for example
[FileNameBodeWrite, PathNameBodeWrite] = uiputfile({'*.xls';'*.csv'},'Save As...',['defname' '.xls']);
if FileNameBodeWrite ~=0
if exist([PathNameBodeWrite FileNameBodeWrite],'file')
delete([PathNameLachWrite FileNameBodeWrite ]);
end
xlswrite([PathNameBodeWrite FileNameBodeWrite ],{'W,rad/s','K,dB','Phase,grad'}) %header
xlswrite([PathNameBodeWrite FileNameBodeWrite ],[w adb p],1,'A2') %data
end
Or point the path manually like this
xlswrite(['D:\DropBox\' name_xls '.xls'], exceloutput, '90CtT 45W','A1');
  1 件のコメント
Bryant
Bryant 2014 年 7 月 2 日
Thank you. Very informative (:

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

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 7 月 2 日
Try this more robust code:
% Get the name of the file that the user wants to save.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath % Or whatever folder you want.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
  1 件のコメント
Bryant
Bryant 2014 年 7 月 2 日
Image Analyst,
Thank you for the quick reply, I'm sorry but can you explain this more in-depth? I'm fairly new to MATLAB. If I were to incorporate this into my script, would i put it before xlswrite or...?

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


Bryant
Bryant 2014 年 7 月 2 日
Thank you both for your help. I have just tested this on my own script and it appears to work. Both your approaches have helped me learn.
Bryant

カテゴリ

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