The ExcelWriteEx function saves data in an Excel file in the XLSX format.

bool = ExcelWriteEx(ssFileName, smMatrix, smType)
bool = ExcelWriteEx(ssFileName, smMatrix)
bool = ExcelWriteEx(ssFileName, rmMatrix)

Return Value

If the function succeeds, the return value is TRUE (1); otherwise it is FALSE (0).



ssFileName is the file name. Normal extension is .xlsx.


smType is a string matrix that defines the type of the corresponding elements in the parameter smMatrix.

Value Meaning
"I" The corresponding element in smMatrix will be converted into a 16 bit unsigned integer number.
"" Empty string. The corresponding element in smMatrix will be converted into a real number.
"S" The corresponding element in smMatrix will be written as a string.

As of version R2020.0, the string "auto" can be given as a third parameter. If "auto" is set, the type matrix will be automatically generated depending of the values given in the parameter smMatrix. If a cell contains a valid number, for example “13.27”, it will be added as a number. “13.27 kg” will be added as a text. See example below.


smMatrix is a string matrix.


rmMatrix is a real matrix.


The maximum number of rows is limited to approx. 1 million rows and 65000 columns.


smData = ["Speed", "Torque";
          "rpm", "Nm";
          "1000.0", "10.5";
          "2000.0", "20.0"];
smType = ["S", "S";
          "", "";
ExcelWriteEx("d:/a.xlsx", smData, smType)
smData = ["Speed", "Torque";
          "rpm", "Nm";
          "1000.0", "10.5";
          "2000.0", "20.0"];
ExcelWriteEx("d:/b.xlsx", smData, "auto")


Version Description
R2020 Parameter "auto"