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

13 次查看(过去 30 天)
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');

更多回答(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

Community Treasure Hunt

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

Start Hunting!

Translated by