A commandline spreadsheet
Monday, June 20, 2005
You can get .NET Sheet at the downloads page.
A tour of .NET Sheet
.NET Sheet is a command line spreadsheet program based on .NET Console, an interactive C# interpreter:
- The CNetConsole class, responsible for controlling command line input and output, is extended in order to support more commands.
- The C#-specific evaluation class CCurlyInterpreter is extended as well, in order to support cell value access, and to perform extended checks on variable names.
Storing Information In Cells
While .NET Sheet is a superset of .NET Console, expressions in the cells are not managed by .NET Console, but by the cells engine (see the CSheet class, which basically wraps a two-dimensional array). The reason for this is that .NET Console variables have no (meta) information associated with them other than their names - in particular, no information about their coordinates.
Still, because cells can be seen like parameterless functions, their values are obtained with function syntax (ig., A1()), even though cells are not .NET Console user functions - expressions rather. There are also special commands for editing the cell expressions: we need to distinguish between evaluating an expression and assigning it to a cell (the set command is used for editing cell expressions).
A related issue is passing cells by reference. For this, cells names are quoted (ig., "A1"), and it's the callee's responsibility to retrieve the cell value. There are two scenarious for this:
- Range functions (they usually take a couple of string arguments). A range function can determine the range by calling CellUtil.ParseCoordinates.
- Using cells as callbacks. Here, the callee can invoke the Cell function (a built-in function defined in CFunctionPool), passing the coordinates.
Keeping the first scenario in mind, it's obvious why cells, although they are very much functions, are not stored as .NET Console user functions: Even though the latter can be passed by reference as well, the callee would have no indication of where in the spreadsheet the range begins or ends, given the just the function object. Therefore, passing by reference is accomplished by passing by name, and from the name, coordinates in the sheet can be deduced.
Other Features
Other features of .NET Sheet include:
- Definition of user functions, which have access read/write access to cell expressions, and read access to cell values. These are, unlike cells, proper .NET Console user functions.
- Definition of regular .NET Console variables.
- XML persistance, including user code (user functions and variables).
- Loading code files interpretable by .NET Console.
Details
[to be supplied]