(Not recommended) Write Microsoft Excel spreadsheet file
xlswrite
is not recommended. Use writetable
, writematrix
, or writecell
instead. For more information, see Compatibility
Considerations.
returns the status of the write operation, using any of the input arguments in
previous syntaxes. When the operation is successful, status is
status
= xlswrite(___)1
. Otherwise, status is 0
.
If your computer does not have Excel for Windows® or you are using MATLAB®
Online™, then the xlswrite
function:
Writes array A
to a text file in
comma-separated value (CSV) format. A
must be a
numeric matrix.
Ignores the sheet
and
xlRange
arguments.
This limitation also applies when the COM server (part of the typical installation of Excel) is not available.
If your computer has Microsoft Office 2003 software, but you want to create a file in an Excel 2007 format, install the Office 2007 Compatibility Pack.
Excel and MATLAB can store dates as text that represents those dates (such as
'10/31/96'
) or serial date numbers (such as
729329
). If your array includes serial date numbers,
convert these dates to their text representation using datestr
before calling
xlswrite
.
To write data to Excel files with custom formats (such as fonts or colors), access the
Windows COM server directly using actxserver
rather than
xlswrite
. For example, this MathWorks Support Answer uses actxserver
to
establish a connection between MATLAB and Excel, writes data to a worksheet, and specifies the colors of the
cells.
Excel converts Inf
values to 65535
.
MATLAB converts NaN
values to empty cells.
dlmwrite
| writecell
| writematrix
| writetable
| xlsfinfo
| xlsread