Effacer les filtres
Effacer les filtres

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

8 vues (au cours des 30 derniers jours)
Bryant
Bryant le 2 Juil 2014
Commenté : Bryant le 2 Juil 2014
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');

Réponse acceptée

Uladzimir
Uladzimir le 2 Juil 2014
Modifié(e) : Uladzimir le 2 Juil 2014
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');

Plus de réponses (2)

Image Analyst
Image Analyst le 2 Juil 2014
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 commentaire
Bryant
Bryant le 2 Juil 2014
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...?

Connectez-vous pour commenter.


Bryant
Bryant le 2 Juil 2014
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