xlswrite
Writes a matrix or cell array to an Excel spreadsheet.
Category: Data Import and Analysis > Data Import and Export
Syntax
xlswrite(filename, A)
Writes A to the first sheet starting at cell A1.
xlswrite(filename, A, sheet)
Writes to the sheet given by number or name.
xlswrite(filename, A, sheet, range)
Writes starting at the cell given by range, such as 'B2'.
Description
Each element of A goes to one cell, so a cell array can hold a header row of text above numeric data. When the file already exists, only the target cells are changed and the rest of the workbook is kept, which allows building a file piece by piece.
The function is kept for older code. writematrix and writecell do the same job with a cleaner interface.
Input arguments
filename- Output
.xlsxfile name. A missing file is created. A- Numeric matrix or cell array mixing numbers and text.
sheet- Sheet index or name. A new name creates the sheet.
range- Top-left cell or a range in A1 notation.
Example
Write, then add a block
xlswrite('sheet_demo.xlsx', [1 2; 3 4]);
xlswrite('sheet_demo.xlsx', [9 9], 1, 'B3');
xlsread('sheet_demo.xlsx')
Output
ans = 3×3
1 2 NaN
3 4 NaN
NaN 9 9