Using GXL to Create Tabular Displays
The G2 XL Spreadsheet (GXL) is a utility that allows you to create, display, and edit tabular data in familiar spreadsheet style. The following figure is an example of a view of a GXL spreadsheet:
You can create GXL displays dynamically or save them as permanent parts of your G2 application on any G2 workspace. These displays can accept user input from the mouse or keyboard, and you can update the displays in real time when data changes in your application. You can also dynamically construct GXL views on UIL dialogs and use them for multiple-column input.
GXL features include:
GXL Specifications
A spreadsheet specification is a graphical layout of objects that serves as a template for creating GXL spreadsheets and views. The following example illustrates a simple GXL specification:
Based on the layout of specification objects, their class, and their attribute values, a specification defines a GXL spreadsheet and a view of the spreadsheet.
Specification objects define two categories of attributes: those related to the spreadsheet and those related to its view. As illustrated in the following figure, GXL first references the spreadsheet properties of the specification to create the spreadsheet, then references the view properties to create the view of the spreadsheet.
You build a specification on a workspace by cloning specification objects from the GXL top-level workspace.
The GXL Spreadsheet
The GXL spreadsheet, the central object in GXL, is an instance of the class gxl-spreadsheet. A GXL spreadsheet contains data that is stored as a two-dimensional grid. You can create a GXL spreadsheet manually from a spreadsheet specification or programmatically by calling API procedures.
Spreadsheet Cells
Each data location in the spreadsheet is referred to as a cell.You reference each cell by its row (R) and column (C) coordinates. The row and column numbering of GXL spreadsheets always begins at 0. As the following figure illustrates, you can refer to a:
Every spreadsheet has definite row and column dimensions, and the maximum size of a GXL spreadsheet is 65535 rows and 65535 columns.
Cell Data Types
Each cell in a spreadsheet has a specific data type, which dictates the valid contents of the cell. Valid data types are:
A cell can also be empty and contain no value.
The GXL Spreadsheet View
A spreadsheet view is the graphical user interface to the data contained in a spreadsheet. A view displays:
For example:
You can customize GXL views by specifying various properties of the cell group specification objects, such as cell dimensions, font size, color pattern, and editing privileges. Typically, a spreadsheet view displays a subset of the cells in a spreadsheet. By scrolling the view you can see any data cell within a cell group of the spreadsheet.
GXL and Conventional Spreadsheets
GXL supports many operations that allow you to manually or programmatically change the spreadsheet structure and values. You can:
While many of the features of GXL are similar to conventional spreadsheets, a number of important differences exist between GXL and conventional spreadsheets:
- GXL does not store formulas as part of the spreadsheet's permanent data structure. The use of formulas is limited to one-time calculation of cell values. Because formulas are not stored, a cell whose value has been calculated from other cells does not automatically update when those cells receive new values.
- A GXL spreadsheet has a definite size which is first established when the spreadsheet is created. The user must specifically add or remove rows and columns to modify the dimensions of the spreadsheet.
- Cells in GXL spreadsheets always have one of the following G2 data types: value, quantity, text, symbol, truth-value, float or integer. Although you can use multiple cell types in a single spreadsheet, you cannot randomly intersperse them.
- Within a single scrolling area, all cells must have the same height and width. You cannot dynamically resize cells on a view after the view is created. If data does not fit into a cell, GXL displays a truncation of the cell's data.
- GXL stores cells that enumerate the rows and columns as part of the spreadsheet's data, rather than as a part of a permanent "frame" outside of the spreadsheet. Inclusion of these cells is optional. This gives you the flexibility to specify the exact appearance of a spreadsheet view.
Using GXL to Edit G2 Lists and Arrays
You can view and edit any G2 class of list or array by using a GXL spreadsheet. When the GXL editing feature is active, choosing edit from a G2 list or array menu displays a view similar to the following:
If the list or array does not contain any data elements, GXL displays a view with an empty data cell.
The GXL editing feature is available from the GXL top-level workspace.
Application Programmer's Interface
All programmatic interactions with GXL take place through a small set of public procedures, classes, and attributes, called the application programmer's interface (API).
Using the GXL application programmer's interface within G2 procedures, you can programmatically create spreadsheet views, populate them with data, and display them on one or more G2 windows. For example, ReThink uses GXL to display summary reports of various statistics associated with model processes, as this figure shows:
You can access workspaces containing the GXL programmer's interface of procedures and methods from the GXL top-level workspace:
Copyright © 1997 Gensym Corporation, Inc.