xlswrite
(Not recommended) Write spreadsheet file
xlswrite
is not recommended. Use writetable
, writematrix
, or writecell
instead. For more information, see Compatibility
Considerations.
Syntax
Description
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
.
Examples
Input Arguments
Output Arguments
Limitations
The
xlswrite
function does not support writing cell arrays that contain different data types when attempting to write CSV files.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
andxlRange
arguments.
This limitation also applies when the COM server (part of the typical installation of Excel) is not available.
Tips
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 as729329
). If your array includes serial date numbers, convert these dates to their text representation usingdatestr
before callingxlswrite
.To write data to Excel files with custom formats (such as fonts or colors), access the Windows COM server directly using
actxserver
rather thanxlswrite
. For example, this MathWorks Support Answer usesactxserver
to establish a connection between MATLAB and Excel, writes data to a worksheet, and specifies the colors of the cells.
Algorithms
Excel converts Inf
values to 65535
.
MATLAB converts NaN
values to empty cells.
Version History
Introduced before R2006aSee Also
writematrix
| writecell
| xlsread
| xlsfinfo
| writetable
| dlmwrite