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.
Yvan Lengwiler (2020). The X Collection (https://www.mathworks.com/matlabcentral/fileexchange/48551-the-x-collection), MATLAB Central File Exchange. Retrieved .
You must be using an older version of the toolbox. If you download the most recent version and reinstall it, it should work.
Its a great tool！
But when i use it to read value of only one cell，such like ‘A1’，it does not work！such as below：
Error using cellfun
cellfun works only on cells.
Error in XRead (line 97)
isText = cellfun('isclass',xlsRaw,'char');
This is amazing!
It should be included in Matlab.
ok, now I see. The problem arises if the decimal separator inside Excel is set to comma instead of point. Thanks for this excellent submission!
very useful and working very well for me under Matlab. However, when compiled to a Matlab standalone the same code is, on some machines (win 7 pro, 64-bit), producing the expected entry values in the generated Excel file. On others the values are by a factor of 1000 too low.
Any ideas what could cause this issue or how to solve it? Thanks, Rolf
Excellent submission, kept up to date with latest MatLab. Much faster than xlsread because it can leave COM connection open, as well as leaving workbook open between calls to different sheets. Easy to use following examples. Note: Example (demo) has one feature that requires financial toolbox. Thanks Yvan!
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)
improved error messages in functions,