ExcelTools - Maple Programming Help

Home : Support : Online Help : Programming : Input and Output : File Manipulation : ExcelTools : ExcelTools/Export

ExcelTools

 Export
 Export an rtable to an Excel spreadsheet

 Calling Sequence Export(R, file, sheet, cell)

Parameters

 R - rtable ; the rtable to export file - string ; (optional in Standard interface) name of the target file sheet - {string, posint} ; (optional) name or 1-based index of the target sheet within the Excel file (default: 1) cell - string ; (optional) address or name of the cell corresponding to the first position in R (default: "A1")

Description

 • The Export(R,file,sheet,cell) function exports the rtable R to the Microsoft Excel format file. Both the XLSX (Office Open XML) and XLS (Excel 97-2003) file formats are supported.
 • If the file does not exist, it will be created. By default, the file is saved in your installation directory. The data in R will be written to the worksheet specified by sheet (which defaults to 1 if not specified), with the first (in the case of a 1-dimensional rtable) or top-left (in the case of a 2-dimensional rtable) entry in R being written to the cell location specified by cell.
 In the Standard interface, if the file parameter is not provided, a dialog will be presented with a field for the target file name. In all other interfaces, the file parameter is required.
 • The cell parameter can be a standard Excel cell reference (for example, "A1", "\$b10") or a named cell location.  In the latter case, the file must already exist and the specified name must refer to a defined name in that Excel spreadsheet.
 If the cell parameter is given as a name or cell range, a warning will be displayed if the corresponding cell range is not of the same dimensions as the rtable R.  The export operation will still be performed.
 • The entries in R will be written to locations in the target which correspond to their locations in R.  For example, if R is an rtable with 2 rows and 3 columns and the target cell is "B2", then the 3rd entry in the 2nd row of R will be written to cell "C4".
 • If R is a Vector, its orientation will be respected in the target file.
 If R is a 1-dimensional Array, it will be exported to a column in the target file.
 Otherwise, R can be a Matrix or 2-dimensional Array.
 • If the export operation will result in data in the target file being overwritten, a warning will be displayed, but the operation will be performed.

Examples

 > $R≔\mathrm{Array}\left(1..3,1..4,\left[\left[1,2,3,4\right],\left[5,6,7,8\right],\left[9,10,11,12\right]\right]\right)$
 ${R}{≔}\left[\begin{array}{rrrr}{1}& {2}& {3}& {4}\\ {5}& {6}& {7}& {8}\\ {9}& {10}& {11}& {12}\end{array}\right]$ (1)
 > $\mathrm{with}\left(\mathrm{ExcelTools}\right):$
 > $\mathrm{Export}\left(R,"Employees.xls","Payroll","B2"\right)$

The destination cells can be specified via a name

Note:  To perform the next example, you should first create an Excel spreadsheet named Employees.xls with a sheet named Payroll and cell named FirstQuarter.

 > $\mathrm{Export}\left(R,"Employees.xls","Payroll","FirstQuarter"\right)$

The sheet can be indexed rather than named.  (To perform this example, the file Employee.xls must have a sheet named Sheet2.)

 > $\mathrm{Export}\left(R,"Employees.xls",2\right)$

(Standard interface only) If the file name is omitted, a dialog opens to request it

 > $\mathrm{Export}\left(R\right)$