getxls
There are of course many ways to import data from an Excel file into Matlab. For instance, by clicking on an Excel file in the 'Current Folder' window within Matlab, one can select data and then push it into a variable in the base workspace. One can also use 'xlsread' to import data programmatically. Moreover, with the ExcelLink Toolbox, you can easily transfer data between Excel and Matlab in both directions, if you have this toolbox (which I don't). 'getxls' is just another possibility which, personally, I find often easier for quickly getting the data into Matlab. The GUI allows you to import either the raw data, just the numeric cells, only the dates cells, only string cells, or the formulas in the speadsheet. If you choose to import only date cells, then the GUI transforms the Excel date code to the corresponding Matlab date code.
The program can be instructive for other software developers as it has a few possibly unusual features. First of all, this GUI was created programmatically, without the help of GUIDE. This makes it, I think, somewhat more transparent. Secondly, and contrary to the code generated with GUIDE, it uses nested functions, which has the advantage that all variables that are defined in the main function are also in the scope of the nested functions. Thirdly, the program demonstrates how to use the Excel COM server. And finally, it demonstrates how to access Matlab's editor and create a new Matlab skript programmatically.
Acknowledgement: A small part of the program is heavily inspired by XLSREAD.
Please comment if you like it or if you find it useful.
Cite As
Yvan Lengwiler (2024). getxls (https://www.mathworks.com/matlabcentral/fileexchange/27799-getxls), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.8 | Added ability to retrieve Excel formulas. |
||
1.7.0.0 | 'editorservices' is no longer supported by the latest version of ML. The new version of GETXLS adapts to this change. |
||
1.6.0.0 | Fixed bug that happened when only a single cell is selected. Moreover, showing Row/Col headings is now the default. |
||
1.5.0.0 | - If no range is selected, the whole worksheet is imported.
|
||
1.4.0.0 | Fixed a minor bug that caused the variable to be pushed to the base workspace twice sometimes. |
||
1.3.0.0 | these updates:
|
||
1.2.0.0 | Added 'Dates' filter to extract only cells that have some date format. |
||
1.1.0.0 | Some improvements:
|
||
1.0.0.0 |