Why do i get an error when using readtable saying cannot open file
조회 수: 106 (최근 30일)
이전 댓글 표시
T=readtable('Technology.xlsx')
Error using readtable (line 223)
Unable to open file 'Technology.xlsx' as a workbook. Check that the file exists, read access is available, and the file is a valid spreadsheet file.
I have made sure i have used the file name correctly and imported the data. But still cannot call for the data.
댓글 수: 4
Walter Roberson
2019년 12월 29일
I have no problem reading the file with readtable() on Mac with R2019b.
If you have R2018b or later, try
T = readtable('Technology.xlsx', 'UseExcel', false);
답변 (2개)
Meindert Norg
2021년 1월 7일
I received the same error while reading a .xlsx from a drive sync'd to OneDrive. I worked around it by first copying the file, and then reading the file with readtable, using this simple script. Hope that helps.
function data = CopyAndReadTable(FullFilename)
%COPYANDREADTABLE copies file and reads table.
%
% Copies a file to the 'tempdir' , then used readtable to
% read the contents. Afterwards the temp file is deleted.
%
% Meindert Norg, 2021.
[~,name,ext] = fileparts(FullFilename);
tempFullFilename = fullfile(tempdir,[name,ext]);
copyfile(FullFilename,tempFullFilename);
data = readtable(tempFullFilename);
delete(tempFullFilename);
end
댓글 수: 0
Hiro Yoshino
2019년 12월 26일
TRY - readmatrix instead:
댓글 수: 1
Walter Roberson
2019년 12월 26일
readmatrix() uses the same code as readtable() to open the xlsx file and read values from it. I would not expect it to work when readtable() does not work.
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!