Can't read Excel files on Linux

조회 수: 16 (최근 30일)
Gerard Capes
Gerard Capes 2018년 4월 13일
댓글: Gerard Capes 2020년 2월 18일
A user has a large number of excel files (.xlsx) to read using `xlsread`. These files open just fine with Excel, and using `xlsread` using R2017a on Windows. Using R2017a on Linux, the files are not recognised as valid Excel files. They will however open just fine with LibreOffice, and if they are re-saved once open in LibreOffice, they will open in MATLAB. Re-saving is not practical given the large number of files involved.
Windows:
>> [status,sheets,xlFormat] = xlsfinfo('input_matrix_4.xlsx')
status =
'Microsoft Excel Spreadsheet'
sheets =
cell
'Sheet1'
xlFormat =
'xlOpenXMLWorkbook'
Linux:
>> [status,sheets,xlFormat] = xlsfinfo('input_matrix_4.xlsx')
status =
0×0 empty char array
sheets =
'Unreadable Excel file: Could not open file /tmp/tpbb084cda_0a2d_463b_8ae0_46fe98df668a/docProps/app.xml. No such file or directory.'
xlFormat =
0×0 empty char array
Is this a bug?
  댓글 수: 2
Marc Compere
Marc Compere 2020년 2월 18일
I'm getting this same result in Ubuntu 18.04.4.
Looks like a feature.
Gerard Capes
Gerard Capes 2020년 2월 18일
I've just dug through my emails to find the resolution to this story :)
The files were generated by STATA, and it seems they weren't quite correct/valid Excel files. Saving them in Excel/LibreOffice was 'fixing' them which allowed MATLAB to read them. This is only a solution if you have a small number of files.
To read the files I had, MathWorks recommended I use readtable and table2array to load the xls files into a matrix.

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

답변 (0개)

카테고리

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