Warning Could Not Start Excel Server For Export Mac. Dec 11, 2012 - you are on MS-Windows but MS-Excel is not installed (if you use. Proliant dl380 drivers for mac.
If you are using Matlab on a MS-Windows PC with MS-Excel installed, there is no problem reading and writing data to Excel (in case your users/customers only understand this software but you still want to do the computations in Matlab). Here is the code to read (1st line) and write (2nd line):
Now, there are several reasons why you may not be able to read and write directly to an Excel file: you have Matlab but
Matlab provides a basic way to read and write in these cases: xlsread()
will only read some xls files (saved as version 97-2003, which should not be an issue – at least this is an Excel file) ; xlswrite()
will only write a .csv file. So you can’t deliver the Excel output.
Fortunately Open Source software is here to help you!
Mercedes benz w123 wagon. Indeed two recently published code on Matlab Central allow you to write “directly” to Excel.
The first solution is provided by Marin Deresco and apparently uses his own binder to Excel. The most simple code is:
I advise you to put the two .jar files in a central location (as done in the code above). That way all you functions will have access to the same version of these files (and updating them for all your projects will be much easier).
But there are three small issues. First the generated matrix will contain only text fields (and they are formatted as text fields, not numbers) ; it doesn’t really matter because Excel can then use this text as numbers directly. Then the second issue is that although it will actually write the requested data, there will be an error when opening the Excel file if you specified a sheet (‘outData’ here) that already exists. Finally you can only start writing at A1.
The second solution is provided by Alec de Zegher, partly in response to the limitation of the previous code. Alec is taking advantage of the Apache POI java library to handle the writing-side. His code also allows to start writing anywhere in the sheet. And it uses the same call structure:
As you can see there are some more .jar to add. On the other hand, it uses a syntax that is very similar to the previous one and to the original Matlab command. Thanks, Marin and Alec, for this great help!
This was tested on Matlab R2012a on a Windows XP 64-bits and with the MCR (same version) on a Windows 2008 64-bits – according to the respective pages for the code, it should work on Mac and other platforms/configurations too.
Photo credits: matlab rubiks cube by gusset, on Flickr (licence by-nc-sa)