com.jrefinery.workbook
Class JWorkbook

java.lang.Object
  |
  +--com.jrefinery.workbook.JWorkbook

public class JWorkbook
extends java.lang.Object

Represents a workbook so that it can be exported to (for now) the Gnumeric XML file format. This class can be used to export data to spreadsheets from Java. The file format can, of course, be read directly into Gnumeric. But there is also a plan to write an importer for Excel (unless there already is one).

Note that this workbook does not have a calculation engine, and I have no plans to add one at this point (too much work!). Maybe one day it will happen, it would be nice...


Field Summary
protected  int geometry_height
          The height of the workbook when displayed in Gnumeric.
protected  int geometry_width
          The width of the workbook when displayed in Gnumeric.
static java.lang.String INDENT
          Standard indentation in the output file.
protected  java.lang.String name
          The workbook name.
protected  java.util.ArrayList names
          Names defined in the workbook - not currently supported.
protected  boolean show_horizontal_scrollbar
          Visibility of the horizontal scroll bar.
protected  boolean show_notebook_tabs
          Visibility of the notebook tabs.
protected  boolean show_vertical_scrollbar
          Visibility of the vertical scroll bar.
protected  Summary summary
          A summary of the workbook.
static java.lang.String VERSION
          Version identification.
protected  java.util.ArrayList worksheets
          The worksheets contained in this workbook.
 
Constructor Summary
JWorkbook()
          Default constructor: creates a new empty workbook.
JWorkbook(java.lang.String name, int sheets)
          Standard constructor.
 
Method Summary
 Worksheet add(java.lang.String name)
          Adds a worksheet with the specified name.
static void main(java.lang.String[] args)
          Test program to demonstrate the idea "in principle".
 void saveAs(java.lang.String filename)
          Saves the workbook in Gnumeric XML format.
 void setAuthor(java.lang.String name)
          Sets the author attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version identification.

INDENT

public static final java.lang.String INDENT
Standard indentation in the output file.

name

protected java.lang.String name
The workbook name.

show_horizontal_scrollbar

protected boolean show_horizontal_scrollbar
Visibility of the horizontal scroll bar.

show_vertical_scrollbar

protected boolean show_vertical_scrollbar
Visibility of the vertical scroll bar.

show_notebook_tabs

protected boolean show_notebook_tabs
Visibility of the notebook tabs.

summary

protected Summary summary
A summary of the workbook.

names

protected java.util.ArrayList names
Names defined in the workbook - not currently supported.

geometry_width

protected int geometry_width
The width of the workbook when displayed in Gnumeric.

geometry_height

protected int geometry_height
The height of the workbook when displayed in Gnumeric.

worksheets

protected java.util.ArrayList worksheets
The worksheets contained in this workbook.
Constructor Detail

JWorkbook

public JWorkbook()
Default constructor: creates a new empty workbook.

JWorkbook

public JWorkbook(java.lang.String name,
                 int sheets)
Standard constructor.
Parameters:
name - The workbook name.
sheets - The number of worksheets in the workbook (initially).
Method Detail

add

public Worksheet add(java.lang.String name)
Adds a worksheet with the specified name. The new worksheet will appear last in the list of worksheets.
Parameters:
name - The worksheet name.

setAuthor

public void setAuthor(java.lang.String name)
Sets the author attribute.
Parameters:
name - The name of the author.

saveAs

public void saveAs(java.lang.String filename)
Saves the workbook in Gnumeric XML format. We don't gzip the output yet, but that will be simple to add...
Parameters:
filename - The name of the file.

main

public static void main(java.lang.String[] args)
Test program to demonstrate the idea "in principle". It writes a text file containing a workbook. Load it up in Gnumeric (spreadsheet on Linux) and see what has been created. The idea is to use this as a means of outputting spreadsheets from Java. An excellent way to write reports...and if I/someone writes an importer for Gnumeric --> Excel (or some code to write directly to Excel format from JWorkbook) then we have the means to create cross-platform spreadsheet output. Quite useful to me...