Reading data from Microsoft Excel

조회 수: 3 (최근 30일)
Kelechi Nwosu
Kelechi Nwosu 2024년 8월 19일
편집: Cris LaPierre 2024년 9월 6일
What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread('amat.xlsx','sheet1','a1:a10')
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea?
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2024년 8월 19일
What is the full error message? Please share all the red text.
Walter Roberson
Walter Roberson 2024년 9월 5일
What shows up if you use
[status, sheets] = xlsinfo('amat.xlsx')

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

채택된 답변

Cris LaPierre
Cris LaPierre 2024년 8월 19일
편집: Cris LaPierre 2024년 8월 20일
Note that xlsread is not recommended. Assuming you are just importing a matrix of numbers, I would use readmatrix.
A = readmatrix('amat.xlsx','Sheet','sheet1','Range','a1:a10')

추가 답변 (1개)

Jatin
Jatin 2024년 8월 20일
There can be few reasons for getting errors while using the “xlsread” function.
Kindly follow these troubleshooting steps to make sure the function work correctly:
  1. Make sure the file is in the current directory or provide the full path to the file.
  2. Use the correct worksheet name and check for spelling and case sensitivity.
  3. Ensure that the range is specified properly, incorrect range may throw errors.
From R2019a, “xlsread” is not recommended as stated in the official documentation. You can switch to using “readtable”,readmatrix” and “readcell instead.
You can refer to the following MathWorks documentations for more information:
  댓글 수: 2
Kelechi Nwosu
Kelechi Nwosu 2024년 8월 30일
Thanks a lot. I did all the suggested and still I was getting errors. I guess I shall have to switch to readmatrix as it is the function that gives the same set of results as xlsread.
Cris LaPierre
Cris LaPierre 2024년 9월 5일
편집: Cris LaPierre 2024년 9월 6일
Consider attaching your file to your post using the paperclip icon. Please share the full error message (all the red text)

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

카테고리

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