FUNCTION REFERENCE
writetable
Write a table to a delimited text file.
Write a table to a delimited text file.
Syntax
writetable(T, filename)Syntax
writetable(T, filename, 'Delimiter', d, 'WriteVariableNames', tf, 'WriteRowNames', tf)Syntax
writetable(T, 'book.xlsx', 'Sheet', s, 'Range', r)For an .xlsx file the same grid is written to a worksheet as xlswrite writes it: Sheet names or numbers the sheet (default the first; a new name adds a sheet), Range gives the top-left cell, and other sheets of an existing workbook are kept.
The first line holds the variable names (a variable with several columns writes Name_1, Name_2, ...), then one line per row. Numbers are written as writecell writes them; text is quoted only when it contains the delimiter, a quote or a line break ('QuoteStrings', true quotes all text); datetime and duration values are written as their display text and logicals as 1 or 0. 'WriteRowNames', true adds the row names as a first column headed by the first dimension name.
Example
writetable(table([1.5; 2], {'a,b'; 'c'}), 'out.csv') % Var1,Var2 / 1.5,"a,b" / 2,cDifferences from MATLAB: .csv, .txt, .dat and .xlsx files only and at most 65536 cells; datetime and duration values are written to spreadsheets as text.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.