Programmatic Spreadsheet Access
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.
>
|
|
| (1.1) |
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.
|
|
Creating Spreadsheets
|
|
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.
>
|
|
| (2.1) |
When no argument 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. If you create a spreadsheet by using the Insert, Spreadsheet menu item, you can determine its name by opening the Properties dialog box that is accessible from the context-sensitive menu for the spreadsheet.
>
|
|
>
|
|
| (2.2) |
|
|
Selecting Cells
|
|
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.
>
|
|
>
|
|
| (3.1) |
Try changing the selected region before executing the following command. You can re-execute this command after selecting different cells with the mouse.
>
|
|
| (3.2) |
This command will copy the selection from the spreadsheet above to the spreadsheet MySpreadsheet that was created earlier.
>
|
|
| (3.3) |
|
|
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).
>
|
|
>
|
|
>
|
|
>
|
|
| (4.2) |
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (4.3) |
|
|
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.
>
|
|
| (5.1) |
>
|
|
| (5.2) |
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (5.4) |
>
|
|
| (5.5) |
>
|
|
|
Return to Index for Example Worksheets
|
Download Help Document
Was this information helpful?