Code covered by the BSD License  

Highlights from
getxls

5.0

5.0 | 2 ratings Rate this file 29 Downloads (last 30 days) File Size: 7.7 KB File ID: #27799
image thumbnail

getxls

by Yvan Lengwiler

 

30 May 2010 (Updated 17 Sep 2011)

GETXLS is a GUI that allows you to easily transfer data from an Excel file into Matlab's workspace.

| Watch this File

File Information
Description

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 direction, 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 eiher the raw data, just the numeric cells, only the dates cells, or only string cells. 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 uses 'editorservices' 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.

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
06 Jul 2010 Yuan  
20 Jan 2011 Moeti Ncube

Dude, u are the man!

Please login to add a comment or rating.
Updates
01 Jun 2010

Some improvements:
(1) callback to edVariable,
(2) toggle row/col headings and buttons for font size,
(3) use of 'genvarname' in case the user selects an invalid variable name,
(4) 'style' argument,
(5) tooltip texts to all objects in the GUI.

07 Jun 2010

Added 'Dates' filter to extract only cells that have some date format.

23 Jun 2010

these updates:
 - added 'generate m-file' functionality
 - fixed bug when resizing window too small
 - fixed bug that manifested on empty worksheets

03 Jul 2010

Fixed a minor bug that caused the variable to be pushed to the base workspace twice sometimes.

13 May 2011

- If no range is selected, the whole worksheet is imported.
- 'Generate M-File' now reads the variablename and uses it for the generated script.

17 Sep 2011

Fixed bug that happened when only a single cell is selected. Moreover, showing Row/Col headings is now the default.

Tag Activity for this File
Tag Applied By Date/Time
gui Yvan Lengwiler 01 Jun 2010 10:30:34
data import Yvan Lengwiler 01 Jun 2010 10:30:34
excel Yvan Lengwiler 01 Jun 2010 10:30:34
spreadsheet Yvan Lengwiler 01 Jun 2010 10:30:34
com server Yvan Lengwiler 01 Jun 2010 10:30:34
excel Fabio 21 Jun 2010 14:06:31
editorservices Yvan Lengwiler 23 Jun 2010 09:53:34
generating code Yvan Lengwiler 23 Jun 2010 09:53:34
spreadsheet Erick Fredj 27 Feb 2012 15:28:32
awsome jeff wu 05 Mar 2012 10:48:14

Contact us at files@mathworks.com