Reading Excel named table doesn't work ?

조회 수: 15 (최근 30일)
Mojert
Mojert 2020년 11월 10일
편집: JE101 2021년 1월 20일
I was trying to read an Excel named table as the documentation of readtable recomend but it doesn't seem to work.
More specificly, with the file that I provided I tried
data = readtable('test.xls', 'Range', 'table');
MATLAB tells me that the range table doesn't exist even though it does. Am I forced to hard code the range (in this case A1:B12) ?
Edit: test.xlsx is a simple spreadsheet that reproduces the behaviour. The real file I'm working on has several tables over multiple sheets that may grow in size later. So I'm interested in being able to refer to the table I'm interested in directly.
  댓글 수: 1
JE101
JE101 2021년 1월 20일
편집: JE101 2021년 1월 20일
I'd be keen to know if anyone has a fix for this too - I've run in to the same problem. As a partial workaround, you can use the old "xlsread" function. Oddly, this does recognise tables defined in Excel. The code would then be:
[numdata, textdata, celldata] = xlsread('test.xlsx', 1, 'table');
The 1 indicates that it's on the first sheet - indicating the sheet seems to be a necessary input (the code doesn't work without it).
Note that this codes doesn't seem to read in the column titles (even in the textdata or celldata) - it only reads in the data in the table.
And I've only tried this with ".xlsx" files. I don't know if it works with ".xls" files.

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

답변 (1개)

Stephan
Stephan 2020년 11월 10일
data = readtable('test.xlsx')
results in:
data =
11×2 table
ID Data
__ _____
1 21324
2 345
3 123
4 -984
5 485
6 3845
7 1674
8 594
9 0.38
10 924
11 947
  댓글 수: 2
Mojert
Mojert 2020년 11월 10일
Ok, maybe I should have specified that this is a simple spreadsheet that reproduces the error but isn't the one I'm working with. The real file has multiple tables over different sheets, so I am interested in being able to specify which table to read.
Thank you for your answer nonetheless !
Stephan
Stephan 2020년 11월 12일
I can only answer on what i get fromm you. Maybe attach the file you have trouble with, will help.

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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by