Octave调用xlsread出现Unzip failed with error 9错误求助
Fixing Octave xlsread "Unzip failed with error 9" for .xlsm Files
Hey, let's work through this error you're facing when using xlsread on a .xlsm file in Octave. I've dealt with similar unzip-related issues with Office Open XML files before, so here are practical solutions to try:
Verify file existence, path, and integrity
- First, confirm the file is in Octave's current working directory. Run
pwdto check your current path, thendirto see iffile.xlsmis listed. If not, either move the file to that directory or use the full absolute path inxlsread, like:xlsread('/Users/yourname/Documents/file.xlsm','Sheet') - This error often pops up if the .xlsm file is corrupted. Try opening it directly in Excel—if Excel can't read it or prompts for repair, you'll need to fix the file (use Excel's repair tool) or get a fresh copy.
- First, confirm the file is in Octave's current working directory. Run
Ensure unzip tool is installed and io package is up-to-date
- Octave's io package relies on system-level unzip to parse .xlsm/.xlsx files. Check if unzip is available by running this in Octave:
If it returns an error, install unzip:system('unzip --version')- Windows: Install 7-Zip and add its
binfolder to your system PATH, or use Git Bash's unzip. - Linux: Use your package manager (e.g.,
sudo apt install unzipfor Debian/Ubuntu). - macOS: If not pre-installed, run
brew install unzip(requires Homebrew).
- Windows: Install 7-Zip and add its
- Update your io package to the latest version—old versions have compatibility gaps with newer .xlsm files:
pkg update io
- Octave's io package relies on system-level unzip to parse .xlsm/.xlsx files. Check if unzip is available by running this in Octave:
Try alternative file formats or functions
- .xlsm files contain macros, which can affect their zip structure. Save the file as a regular .xlsx in Excel (File > Save As > Excel Workbook (*.xlsx)), then run
xlsreadon the new file. - Use Octave's
readtablefunction (part of the io package) instead—it has better support for modern Excel formats:
You can then extract data from the table using standard indexing, likedata_table = readtable('file.xlsm', 'Sheet', 'Sheet');data_table.Column1.
- .xlsm files contain macros, which can affect their zip structure. Save the file as a regular .xlsx in Excel (File > Save As > Excel Workbook (*.xlsx)), then run
Check file permissions
- Make sure Octave has read access to the file:
- Windows: If the file is in a protected folder (e.g.,
C:\Program Files), launch Octave as Administrator. - Linux/macOS: Run
chmod +r file.xlsmin the terminal to grant read permissions.
- Windows: If the file is in a protected folder (e.g.,
- Make sure Octave has read access to the file:
Hope one of these steps resolves the unzip error for you!
内容的提问来源于stack exchange,提问作者user2960842
相关产品推荐
相关产品推荐

