필터 지우기
필터 지우기

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');

추가 답변 (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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by