Programmatic Spreadsheet Access
Important: The Spread package has been deprecated.
This worksheet demonstrates some of the features of the Spread package. This package is intended to provide support for accessing Maple spreadsheets programmatically. As you read this worksheet, you should execute the commands in sequence as you come to them.
Accessing the Spread Package
To use the Spread package, you must first issue the following call to the procedure with, which provides interactive access to procedures organized into packages.
The routines exported by the Spread package are now available for interactive use. The procedures available in the package are displayed as the result of the with command.
The first task with which you must become acquainted is the programmatic creation of spreadsheets. When a spreadsheet is created, it is given a name. The procedure CreateSpreadsheet is provided for programmatic control of spreadsheet creation. The name of the spreadsheet is returned. You must use this name to refer to the spreadsheet in subsequent calls to Spread package procedures.
Now, the variable ssid is assigned the name of the spreadsheet that was created by executing the preceding command.
When no arguments are provided, CreateSpreadsheet returns a system-generated name for the spreadsheet. You can also specify your own name for the spreadsheet by providing that name as an argument to the call to CreateSpreadsheet. You can find the name of a spreadsheet by opening the Properties dialog box that is accessible from the context-sensitive menu for the spreadsheet.
Every spreadsheet has, at all times, a "current selection". This refers to the box-shaped region of cells that are visually distinguished from those that do not belong to the selection. Many of the Spread package procedures operate on and allow you to manipulate the current spreadsheet selection.
Try changing the selected region before executing the following command. You can re-execute this command after selecting different cells with the mouse.
This command will copy the selection from the spreadsheet above to the spreadsheet MySpreadsheet that was created earlier.
Evaluating Cells and Manipulating Cell Data
You can evaluate either an entire spreadsheet, or just the current selection (which you can set using the procedure SetSelection), by using the commands EvaluateSpreadsheet and EvaluateCurrentSelection, respectively.
The command GetCellValue will retrieve the (displayed) value from a specified cell. The formula stored in a given cell can be queried by using the command GetCellFormula. By using SetCellFormula, you can set the formula of a cell (but not the cell value).
for i from 1 to N do for j from 1 to N do SetCellFormulassid,i,j,diffBesselJi,x,x$j end do end do:
for i from 1 to N do for j from 1 to N do SetCellFormulassid,i+N,j,evalGetCellFormulassid,i,j,x=0 end do end do:
Performing Block Operations with Matrix Data
Sometimes it is convenient to manipulate entire blocks of data within a spreadsheet. Such blocks can be represented in Maple using matrices. Certain commands in the Spread package allow you to manipulate spreadsheet data in a blockwise fashion, using matrices.
The Procedure SetMatrix inserts a matrix of values into a spreadsheet. Blocks of data can be extracted from a spreadsheet by using the commands GetValuesMatrix and GetFormulaeMatrix. You can import matrix data into a spreadsheet selection, with clipping, by using the command InsertMatrixIntoSelection.
Return to Index for Example Worksheets
Download Help Document