xls2struct

버전 1.5.0.0 (8.2 KB) 작성자: Ashish Uthama
Load Excel file contents as a structure
다운로드 수: 3.5K
업데이트 날짜: 2010/5/20

라이선스 보기

xls2struct Load Excel file contents as a structure
xlsstruct = xls2struct(file) loads the Excel file 'file'. The first row is
used to generate the field names for the 1x1 structure xlsstruct. Each
column (excluding the first row) is then converted to a numeric/cell
array and assigned to the corresponding field name. All columns are
expected to have equal number of entries.

xlsstructArray = xls2struct(file,'structArray') will return a 1xNumCol
structure array xlsstructArray. The kth element of the structure will
have field names corresponding to the first row and values corresponding
to the kth row.

GENVARNAME is used to generate a valid MATLAB structure field name from
the first row data.

Blank entries are returned as 'NaN'.

Platform support is dependent on XLSREAD.

%Example: Given this Excel file content (9 columns, 5 rows):

%one two three four ' ' six se ven
%1 2 3 6 7
%11 22 three
% seven
% 222 33

xlsStruct=xls2struct('example.xls')
% Where:
% xlsStruct.one' = 1 11 NaN NaN
% xlsStruct.two' = 2 22 NaN 222
% xlsStruct.three' = [3] 'three' [NaN] [33]
% xlsStruct.four' = NaN NaN NaN NaN
% xlsStruct.x' = NaN NaN NaN NaN
% xlsStruct.six' = 6 NaN NaN NaN
% xlsStruct.seVen' = [7] [NaN] 'seven' [NaN]

xlsStructArray=xls2struct('example.xls','structArray')
% Where:
% xlsStructArray =
%
% 1x4 struct array with fields:
% one
% two
% three
% four
% x
% six
% seVen

인용 양식

Ashish Uthama (2024). xls2struct (https://www.mathworks.com/matlabcentral/fileexchange/19707-xls2struct), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2010a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Spreadsheets에 대해 자세히 알아보기
도움

줌: xls2mat

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.5.0.0

* Fixed bug when first column is all text. (num matrix returned by XLSREAD has one less column)

1.4.0.0

* significant rewrite - add support to return structure arrays

1.3.0.0

* suppressed inconsequential mlints
* fixed bug while handling mixed type of data ( ex: 1 2 'a' 'b')

1.1.0.0

*Use dynamic structure field names instead of eval
*More flexibility for input data format in excel sheet

1.0.0.0