How to make "xlswrite" "writetable" ACTUALLY work for output excel files?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
my
am 27 Sep. 2015
Kommentiert: Walter Roberson
am 29 Apr. 2025
seems that people had the same issues in the past and there is no well-established solutions.
I have 2015a Matlab on a mac and got my excel from my university network (download and install). This is the case for most of students and faculty members. However, xlswrite says
"Warning: Could not start Excel server for export. XLSWRITE will attempt to write file in CSV format. > In xlswrite (line 174)"
writetable says: "Error using writetable (line 106) Could not start Excel server for export. Export to a text file instead."
I am very shocked about this, since these two commands are so essential. Please help.
Henry
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 28 Sep. 2015
Bearbeitet: Walter Roberson
am 29 Apr. 2025
The first thing you would have to do is convince Microsoft to compile Microsoft Office for Mac with some COM library for Unix / Linux, because it literally is not compiled to support the COM interface at present.
You would then need to get the various distributors of Unix and Linux to agree upon a compatible interface and implement it and test it and add it to the distributions.
The below item talks about some of the technical measures involved, from the perspective of a few years ago. They casually mention DCE as being needed to deal with multiple architectures. I had some experience with DCE in a past position; it is a pain in the posterier to get right. It also used to be quite expensive, but perhaps that has been overcome. Note in this regard that Microsoft's COM implementation cannot even talk between 32 bit and 64 bit processes and so is just not ready for the Linux world of different chips and different byte orders.
With regards to the current situation on Linux, see http://stackoverflow.com/questions/3063321/is-there-an-equivalent-to-com-on-nix-systems-if-not-what-was-the-nix-approa
3 Kommentare
Walter Roberson
am 28 Sep. 2015
Mac OS-X is not Linux, as Linux is a Unix like operating system. OS-X is a version of Unix, repeatedly certified as such; see http://unix.stackexchange.com/questions/1489/is-mac-os-x-unix. That means that it has been certified to meet all the mandatory standardized interfaces for Unix, and is therefore inter-operable with all other version of Unix. If Microsoft were to use a standard Unix interface to provide Component Object Model services then it would work on OS-X. But Microsoft does not use any standardized interfaces for COM, only proprietary interfaces.
Which language have you found for OS-X that supports access to COM objects that talk to Excel ?
If you are talking about languages that have functions that write xls files, then
- Maple can write xlsx (2007, XML text based) and xls (1997, 2003) but not xlsb or xls 2007 binary
- Mathematica can write xlsx (2007, XML text based) and xls (Excel 2000 only)
I do not know at the moment if Maple or Mathematica have restrictions on OS-X.
Walter Roberson
am 29 Apr. 2025
The above said... there is a writetable() option known as 'UseExcel'.
In modern releases, it defaults to false for all file types; writetable() contains internal code that knows how to handle xlsx binary files.
In early releases after writetable() was released (R2013b), UseExcel defaulted to true on Windows. So the solution in the R2015 time frame would be to explicitly specify 'UseExcel', false
Weitere Antworten (1)
Yang
am 29 Apr. 2025
You can add a FileType definition in the statement as follows:
filename = sprintf('Schedule for %s.xlsx', data);
writetable(table, filename, 'FileType', 'spreadsheet');
1 Kommentar
Walter Roberson
am 29 Apr. 2025
writetable() by default examines the file extension in order to detect that xlsx was requested, and it knows that xlsx is Filetype spreadsheet. So specifying FileType spreadsheet for writetable() is not necessary . Specifying it might be a nice bit of self-documenting code for certainty, but it has never been necessary when .xlsx is specified as the file extension.
Siehe auch
Kategorien
Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!