Use the following two functions to read from, or write to Excel files:
• READEXCEL("file", [“range”, [emptyfill, [blankrows]]])—Returns a matrix from a defined range in an Excel file.
• WRITEEXCEL("file", M, [rows, [cols]], [“range”])—Writes matrix M to the defined range within the Excel file you specified.
Both functions support the XLS and XLSX file extensions.
To execute these functions, you must use variable assignment or expression evaluation as follows:
Arguments
• “file” is a string containing the filename or the full pathname and filename. You must include the XLS or XLSX file extension, for example, heat.xlsx. Non-absolute pathnames are relative to the current working directory.
• “range” (optional) is a string containing the cell range. If this argument is omitted, then READEXCEL reads all the data in "Sheet1" of the specified file and WRITEEXCEL writes all the data in the specified matrix to "Sheet1" of the specified file.
You can specify range in one of the following forms:
◦ "Sheet1!A1:B3" specifying the worksheet name, the top left cell, and the bottom right cell. "Sheet1!A1" means cell A1 of Sheet1, and "Sheet1" means the entire worksheet.
◦ "[1]A1:B3" specifying the worksheet number, the top left cell, and the bottom right cell. "[1]A1" means cell A1 of Sheet1, and "[1]" means the entire worksheet.
• emptyfill (optional) is a string, scalar, or NaN (default), which is substituted for missing entries in the data file.
• “blankrows” (optional) is a string that specifies what to do when encountering a blank line:
◦ skip—Skips the current line.
◦ read—(default) Reads the blank line.
◦ stop—Stops the reading process.
• M is a matrix of scalars. If M contains units, functions, or embedded matrices, PTC Mathcad cannot write the file.
• rows or cols (optional) are either scalars specifying the first row or column of matrix M to write, or two-element vectors specifying the range of rows or columns (inclusive) of matrix M to write. If you omit this argument, WRITEEXCEL writes out every row and column of the matrix to the specified file.
Additional Information
• Both rows and cols are indices that start with 1. System variable ORIGIN has no effect on the behavior of the READEXCEL or WRITEEXCEL functions.
• You can only omit optional arguments from the last argument and back. For example, in WRITEEXCEL you cannot omit rows and specify cols. If you omit rows, the value of cols is used as rows.