RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • arrayDatastore
    • csvread
    • csvwrite
    • detectImportOptions
    • dlmread
    • dlmwrite
    • fileDatastore
    • parquetDatastore
    • parquetinfo
    • parquetread
    • readcell
    • readmatrix
    • readtable
    • readtimetable
    • spreadsheetImportOptions
    • writecell
    • writematrix
    • writetable
    • writetimetable
    • xlsread
    • xlswrite

xlswrite — Write numeric, logical, string, character, or cell data to Excel-compatible spreadsheet files.

xlswrite provides MATLAB's legacy spreadsheet export forms for older scripts. It writes an OOXML workbook payload for .xlsx and legacy .xls filenames, accepts worksheet and range selectors, preserves supported cells in workbooks previously created by RunMat xlswrite, and returns status/message outputs when requested.

Syntax

status = xlswrite(filename, A)
status = xlswrite(filename, A, sheetOrRange)
status = xlswrite(filename, A, sheet, range)
status = xlswrite(filename, A, sheet, range, '-basic')
[status,message] = xlswrite(filename, A)
[status,message] = xlswrite(filename, A, sheetOrRange)
[status,message] = xlswrite(filename, A, sheet, range)
[status,message] = xlswrite(filename, A, sheet, range, '-basic')

Inputs

NameTypeRequiredDefaultDescription
filenameStringScalarYes—Spreadsheet file path.
AAnyYes—Numeric, logical, string, character, or cell data to write.
sheetOrRangeAnyYes—Worksheet name/index or Excel A1 range start.
sheetAnyYes—Worksheet name or one-based worksheet index.
rangeStringScalarYes—Excel A1 range start or range.
modeStringScalarNo"basic"Legacy '-basic' compatibility flag.

Returns

NameTypeDescription
statusLogicalArrayTrue when the spreadsheet was written successfully.
messageAnyDiagnostic struct with message and identifier fields.

Returned values from xlswrite depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:xlswrite:InvalidArgumentArgument list does not match supported xlswrite call forms.xlswrite: invalid argument
RunMat:xlswrite:FilenameFilename is invalid or cannot be normalized.xlswrite: invalid filename
RunMat:xlswrite:RangeRange specification is malformed or exceeds worksheet limits.xlswrite: invalid range
RunMat:xlswrite:SheetWorksheet selector is invalid.xlswrite: invalid sheet
RunMat:xlswrite:DataInput data cannot be represented as supported spreadsheet cells.xlswrite: invalid data
RunMat:xlswrite:IoSpreadsheet cannot be written.xlswrite: unable to write spreadsheet
RunMat:xlswrite:OutputCountCaller requests more outputs than xlswrite supports.xlswrite: unsupported output count

How xlswrite works

  • xlswrite(filename, A) writes A to the first worksheet starting at A1. If the filename has no extension, .xlsx is appended.
  • xlswrite(filename, A, sheet) selects a worksheet by name or one-based numeric index.
  • xlswrite(filename, A, range) writes to an A1-style range start such as "B2" on the default worksheet.
  • xlswrite(filename, A, sheet, range) combines worksheet and range selection.
  • When the destination workbook already exists and was created by RunMat xlswrite, xlswrite preserves supported existing worksheets and cells outside the overwritten range.
  • Existing unmarked Excel workbooks are rejected instead of being flattened into RunMat's minimal workbook representation; this avoids silently discarding formulas, macros, styles, charts, images, or workbook metadata.
  • Numeric sheet selectors are one-based worksheet ordinals. Missing ordinal sheets are created as SheetN placeholders so later xlsread(filename, N, ...) calls address the same worksheet.
  • Numeric, sparse, logical, string, character, and heterogeneous cell inputs are supported. Values from all eight native integer classes serialize exactly; cell contents must be scalar spreadsheet values.
  • A numeric worksheet index may use any native integer class and is decoded exactly.
  • A1 ranges may use absolute markers such as $B$2:$C$3; malformed range endpoints are rejected.
  • The legacy '-basic' mode flag is accepted as a no-op because RunMat writes spreadsheets directly rather than using Excel COM automation.
  • RunMat mode accepts a numeric row and column vector in the range position and accepts explicit gpuArray input; both are gated before file access.
  • status = xlswrite(...) returns true on success. [status,message] = xlswrite(...) captures write failures as false plus a diagnostic struct with message and identifier fields.

Does RunMat run xlswrite on the GPU?

xlswrite performs host file I/O. Automatic residency is gathered through the owning provider, while explicit device intent is compatibility-gated before provider or file access.

GPU memory and residency

xlswrite consumes host-side file data. Automatically resident values gather transparently; explicit gpuArray input requires RunMat mode. Outputs are host status/message values.

Examples

Write a numeric matrix

status = xlswrite('measurements.xlsx', [1 2 3; 4 5 6]);

Write to a named worksheet and range

status = xlswrite('measurements.xlsx', {'Voltage', 1.5, true}, 'Data', 'B2');

Capture a failure message

[status, message] = xlswrite('out.xlsx', 1+2i);
if ~status
    disp(message.message)
end

Using xlswrite with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how xlswrite changes the result.

Run a small xlswrite example, explain the result, then change one input and compare the output.

FAQ

Does xlswrite use Microsoft Excel?⌄

No. RunMat writes workbook files directly on the host. The '-basic' flag is accepted for compatibility, but COM automation is not used.

What happens with .xls filenames?⌄

RunMat accepts legacy .xls filenames and writes the same OOXML workbook payload used for .xlsx. This keeps old scripts running in RunMat and remains readable by RunMat's content-based spreadsheet reader.

Can xlswrite update an existing Excel workbook created elsewhere?⌄

No. RunMat rejects unmarked existing workbooks rather than rewriting them as a minimal value-only workbook and losing formulas, macros, formatting, charts, images, comments, or metadata.

What should I use for new code?⌄

xlswrite exists for legacy MATLAB compatibility. For new code, prefer writematrix, writecell, or table-oriented export APIs where available.

Related Io functions

Tabular

arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread

Net

accept · read · readline · tcpclient · tcpserver · write

Repl Fs

addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite

Audio

audioinfo · audioread

Io

clc · diary · disp · display · format · input

Filetext

fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines

Archive

gunzip · gzip · unzip

Hdf5

h5disp · h5info · h5read · h5write · h5writeatt · hdf5info · hdf5read · hdf5write

Import

importdata · textscan

Json

jsondecode · jsonencode

Mat

load · matfile · save

Http

sendmail · urldecode · urlencode · weboptions · webread · websave · webwrite

Related guides

  • MATLAB language extensions

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how xlswrite is executed, line by line, in Rust.

  • View the source for xlswrite in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How xlswrite works
  • Does RunMat run xlswrite on the GPU?
  • GPU memory and residency
  • Examples
  • Write a numeric matrix
  • Write to a named worksheet and range
  • Capture a failure message
  • Using xlswrite with coding agents
  • FAQ
  • Related Io functions
  • Tabular
  • Net
  • Repl Fs
  • Audio
  • Io
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Related guides
  • Open-source implementation
  • About RunMat