필터 지우기
필터 지우기

what would be the command to save or open a particular excel data.xls with the designation in a particular drive or folder?

조회 수: 1 (최근 30일)
xlswrite might be the one, but I don't know how to add the information on the destination to save data. Same question to xlsread to search and read a file.

채택된 답변

Cedric
Cedric 2017년 10월 10일
편집: Cedric 2017년 10월 10일
Here is an example. Make sure that the destination folder exists already. If not or if you have to create destination folders dynamically, use EXIST for testing if they exist already and MKDIR for making them if necessary.
data = randi( 10, 5, 3 ) ;
header = {'A', 'B', 'C'} ;
% - Build cell array of mixed content (strings and numbers).
data = [header; num2cell( data )] ;
% - Concatenate path bits to relevant destination file/folder.
locator = fullfile( '..', 'Data', 'Measures.xlsx' ) ;
% - Build Excel file.
xlswrite( locator, data ) ;
  댓글 수: 3
yasu osako
yasu osako 2017년 10월 10일
편집: Cedric 2017년 10월 10일
I got the error as below.
>> header={'a','b','c'};
>> data=randi(10,5,3);
>> locator=fullfile('..','data','measures.xls');
>> xlswrite(locator,data);
Error using xlswrite (line 226)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: ???? 'C:\Users\Minori2\AppData\data' ????????????????????????????
· ??????????????????????????
· ?????????????????????????????????????????????????????????????????????????????????
· ???????????????????????????????????????????????????????????????????
Help File: C:\Program Files (x86)\Microsoft Office\Office\1041\xlmain9.chm
Help Context ID: 0
Cedric
Cedric 2017년 10월 10일
편집: Cedric 2017년 10월 10일
It was for building a path that targets a folder at the same level as the current folder.
Let's try to write to a file in the same folder first, to eliminate the complication of building a path: does the following work?
header={'a','b','c'};
data=randi(10,5,3);
xlswrite('test.xlsx',data);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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