Gridlock
By Al Williams
When personal computers first appeared on the scene, many people bought them purely to run spreadsheets (notably VisiCalc, at the time). The spreadsheet was a compelling application that appealed to many people. With the Web taking firm root in the computing landscape, it's no surprise that many applications require a spreadsheet-like interface.
You could just write an applet or an HTML table to do specific calculations. In previous Java@Work installments I've written applets that compute electrical formulae and home mortgages. These are traditional tasks for a spreadsheet, but I just wrote the code for the spreadsheet functions directly. Instead of appearing as a spreadsheet, these applets are custom forms, and Java powers their calculations.
Even though these applets work without a spreadsheet interface, many users would find a spreadsheet interface to programs like them more comfortable and familiar. You might also be interested in a spreadsheet-like Web page if you're moving existing spreadsheets to the Internet.
Writing a custom spreadsheet might be more work than you want to tackle. At first glance, it seems simple enough. However, there are many pitfalls. For example, when recalculating a spreadsheet it is necessary to compute cells in the correct order so that formulae that depend on other cells work correctly. Otherwise, this can lead to recursion and, if you're not careful, infinite loops.
The correct solution is to analyze the spreadsheet as a directed graph. Luckily, you don't have to delve into this level of esoterica -- you can just buy a Java component that does the job.<>