Donate Share

Bean Sheet

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

How does beansheet work?

You are viewing a single message from this topic. View all messages.

  1. 2007-11-20 01:42:59 UTC
    Ron,

    Thank you for your interest. I'd suggest you have a look at the Introduction > Syntax section in help for some introductory tips on getting the basics of cell references. That said, I'll go over some common mistakes one can make when starting to use Bean Sheet.

    1. Cell editing
    There are 3 ways to edit a cell: inline (double clicking a cell within the cell grid), quick editor (select a cell and edit its text in the textbox on top; press Enter to make the change take effect), and multiline editor (Edit > Cell Editor from the menu bar, Ctrl+E keyboard shortcut, or the Edit Cell button from the toolbar).

    2. Entering formulas
    When entering cells that require formula evaluation, some things will be familiar to Excel users, but one really needs to understand the basics of Java syntax for anything but the simplest scenarios. Like in traditional spreadsheets, a formula cell must begin with the equal sign ("="). Everything in Bean Sheet's cells is an object or a null. Even text entered into cells explicitly is in fact a String object. For instance, enter "1" into cell A0 and "2" into B0. Now let's enter the following formula into cell A2: "= a0 + b0". Uh oh, an error:

    Sourced file: inline evaluation of: `` a0 + b0;'' : illegal use of undefined variable, class, or 'void' literal : at Line: 1 : in file: inline evaluation of: `` a0 + b0;'' : ;

    It's a common mistake for a traditional spreadsheet user. In Bean Sheet, the syntax for cell references is a bit different. We have to use brackets. Let's fix the formula to this: "= [a0] + [b0]". Now there's no error, but something's terribly wrong, it seems 1 + 2 is 12. What happened? Bean Sheet doesn't automatically detect the type of text entered and translate it into, let's say, an integer without explicit steps taken by the user. Instead, if one simply types some text that's not a formula, it'll be interpreted as a String object. And of course, a plus sign applied to String's acts in Java as a concatenation operator. Indeed, in Java speak, what we're doing is "1" + "2", which is understandably "12". I made this decision conscious of the fact that it will create some usability problems for a novice user. But trust me, the benefits outweigh some of these initial pains. So how do we fix this?

    3. Controlling cell type
    To show that we are indeed operating with String objects, let's enter the following into A1 and B1 respectively: "= [a0].getClass()", "= [b0].getClass()". Voila -- they both produce "class java.lang.String".

    There are 2 primary ways to make a cell hold something other than a String. The first way is by making those cells themselves formulas and expressing the type via Java syntax. For example, let's change A0 to "= 1". Notice that A1 now says "class java.lang.Integer". But A2 is still "12", which is because we're applying the + operator to a mixed set of inputs, one an integer and the other a String. We can do the same thing to B0 and we'll get the result we want, but I'll show you another method of controlling cell type, one that is generally more flexible. Select B0 and go to Table > Cell Format from the menu bar. Select Number from the left drop-down list. The default number format pattern will appear in the right drop-down list as "#0", which is fine for this example. More information about cell formats can be found in help. Let's accept the change by clicking OK. The cell format has now changed, but the object in B0 is still a String, as can be evidenced by the value in B1. That's because despite the fact that the format expects a number in that cell, it is not automatically applied to previously entered values. This was originally on purpose, but I am currently considering making a change to this behavior. Anyway, let's tell Bean Sheet to apply the format to B0. The easiest way is to simply re-edit it in any of the ways I outlined above. We don't need to change the text, we just need to "re-enter" it so to speak. As soon as we re-enter "2" in B0 and accept it, just like that, we see "class java.lang.Long" in B1 and "3" in A2.

    This may seem like a whole lot of trouble for such a simple thing, but that's simply because Bean Sheet's focus is power of the Java language and virtual machine applied in the framework of a spreadsheet rather than ease of coming up to speed. I do intend to add some more documentation and touch up on a few usability features, but I just want to communicate that this is really not meant to be an Excel alternative for a casual user. Hope this helps. Let me know if you have any other questions or bug reports. Enjoy!
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.