Why do i get an error when using readtable saying cannot open file

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
Walter Roberson 2019 年 12 月 23 日
If the file is in your current directory, and you have read access to it, then it is either corrupt or not a .xlsx format file.
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2019 年 12 月 26 日
Hi Jessie,
As mentioned by @Walter, you shouldn't have problems reading an Excel file if you have the right path and permissions. Please share your file that is causing this issue, so that we can see if this problem that you describe can be recreated.
Jessie Xin
Jessie Xin 2019 年 12 月 27 日
This is the Excel file that causing this issue.
Walter Roberson
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
Meindert Norg 2021 年 1 月 7 日

1 投票

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
Hiro Yoshino
Hiro Yoshino 2019 年 12 月 26 日

0 投票

1 件のコメント

Walter Roberson
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.

サインインしてコメントする。

タグ

質問済み:

2019 年 12 月 23 日

回答済み:

2021 年 1 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by