The X Collection

Collection of programs that ease interaction with Excel files.
Updated 21 Jan 2015

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

The X collection is a set of Matlab programs that make it easier for the user to interact with Excel sheets. Matlab offers already many ways of exchanging data with Excel. For instance 'xlsread' and 'xlswrite' allow the programmer to read data from and write data into Excel worksheets. But these programs are inefficient when a large number of read and write operations have to be repeated because they build a connection to the Excel COM server and then release this connection again with every operation.

The X collection splits that up. The programmer creates a connection to Excel (with XConnect), then does whatever he or she has to do (XWrite, XRead, XOpenBook, XGetSheet, XSaveBook etc), and then releases the Excel connection again (XDisconnect). Depending on the type of work, the gain in speed range from none at all to orders of magnitude.
The following programs are included: XConnect, XDisconnect, XListOpenBooks, XGetBook, XNewBook, XOpenBook, XFetch, XSaveBook, XSaveAllBooks, XCloseBook, XCloseAllBooks, XListSheets, XGetSheet, XAddSheet, XRead, XWrite, XWriteDates, XDateFmt, XRangeAddress.

Their meanings should be more or less obvious. They all come with help, so that you user should be able to figure out how to use these programs fairly easily. There is also a short documentation (PDF file) as well as an example script (examples.m) that demonstrates many of these programs.

Should you need help with this, please contact me. If you find this contribution useful, please comment below.

Cite As

Yvan Lengwiler (2024). The X Collection (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Access to online worksheets was possible with XOpenBook already, but XFetch provides even easier access to files on Yahoo Finance, Google Finance, FRED Database of the FRB St.Louis, and Penn World Table 8.0.

XOpenBook now handles Excel files that are online and opens them directly

XWrite now also handles tables.

New support for exporting Matlab figures into Excel worksheets (with XWrite)
Ranges can now be in coordinate form (i.e. [3,2]) or in 'A1'-style (i.e. 'B3')

improved error messages in functions,
corrected typos in description in FEX