<< xlread xlreadwrite

xlreadwrite >> xlreadwrite > xlwrite

xlwrite

Write to Microsoft Excel spreadsheet file using Java

Syntax

xlwrite(file_path,A)
xlwrite(file_path,A,sheet)
xlwrite(file_path,A,range)
xlwrite(file_path,A,sheet,range)
status = xlwrite(...)

Arguments

file_path

a character string giving the path of the Excel file. If the file does not exist, xlwrite creates a file, determining the format based on the specified extension, .xls or .xlsx (the default if no extension is given).

A

Two-dimensional logical, numeric or string matrix or, if each cell contains a single element, a cell array.

sheet

an integer giving the sheet position or a character string giving the sheet name. If does not exist, xlwrite adds a new sheet at the end of the worksheet collection.

range

a character string giving the rectangular range to be writen in the sheet using Excel syntax. If range is larger than the size of A, xlwrite fills the remainder of the region with #N/A. If range is smaller than the size of A, xlwrite writes only the subset that fits into range to the file.

status

a boolean with value %t if write opration was successfull and %f otherwise.

Examples

sheetName = 'this_is_sheetname';
startRange = 'B3';

// Generate some data
xlsData = {'A Number','Boolean Data','Empty Cells','Strings'
    1, %f, [], 'String Text'
    5, %f, [], 'Another very descriptive text'
    -6.26, %f, 'This should have been an empty cell but I made an error' 'This is text'
    1e8, %t, [], 'Last cell with text'
    1e3, %f, %nan, %nan
    1e2, %t, [], 'test'};

// Generate XLS file
xlwrite('TMPDIR/test.xls', xlsData, sheetName, startRange);
// Generate XLSX file
xlwrite('TMPDIR/test.xlsx', xlsData, sheetName, startRange);

See also

Bibliography

This function is based on POI library (http://poi.apache.org/).


Report an issue
<< xlread xlreadwrite