GullFOSS
OpenOffice.org Engineering at Sun
 
 
 
 
More Flickr photos tagged with openoffice

Today's Page Hits: 2122

Locations of visitors to this page
« AAWAX or How to... | Main | New: OpenOffice.org... »
Wednesday, 07 Mar 2007
odf4j at work in EIS
Bernd Eilers

Lars Oppermann recently started the odf4j (odf for java) subproject of the OpenOffice.org ODF Toolkit project. I had some experimental stuff for ODF file handling in java lying around, merged that with what lars provided as initial java sources for odf4j added some new stuff and contributed the result to odf4j. And than EIS is now using this library to provide "View as OpenDocument (Calc)" links on every HTML page in EIS where one or more tables are being shown. That means that you can request every data you can get from EIS, especially the Statistics as an OpenDocument Spreadsheet document.

Doing something like this is very easy with the things now available in odf4j. If you´ve got some database query and want to create an OpenDocument SpreadsheetDocument from the result what you basically do is:

import org.openoffice.odf.spreadsheet.SpreadsheetDocument;
import javax.swing.table.TableModel;
import javax.swing.table.DefaultTableModel;
import java.sql.ResultSet;
import java.sql.Statement;
import java.io.OutputStream;
//...

public class MyClass {

public void createDocument(OutputStream out, String uri) {
SpreadsheetDocument doc=new SpreadsheetDocument();

// do database query
// ...

// create table model
TableModel model=new DefaultTableModel();

// fill model with result of database query
//...

// create Spreadsheet in the SpreadsheetDocument based on the data in the model
doc.addSpreadsheet("data",model);

// the SpreadsheetDocument constructor created a document with one empty Spreadsheet
// named "Sheet1" this Spreadsheet is not needed anymore, so we delete it
doc.deleteSpreadsheet("Sheet1");

// store the document
doc.save(out,uri);
}
// ...
}

The OpenOffice.org ODF Toolkit project and it´s odf4j subproject have just been started some time ago and are still seeking for people helping the effort.

You can checkout odf4j from OpenOffice.org CVS via:

cvs -d:pserver:anoncvs@anoncvs.services.openoffice.org:/cvs co odftoolkit/odf4j

So far besides the stuff just mentioned for Spreadsheet Documents there´s not much specific functionality for document manipulation and information in there yet, but the basic stuff for working with the OpenDocument Package file format is there and we also have helper stuff for general XML manipulation (eg. XSL Transformation or working with org.w3c.dom trees) of ODF content etc. As demonstrated with the new EIS feature there are already use cases for where what we now have can be used in productive environment, altough it´s just all pretty alpha ;-). So well maybe you like what we´ve started and probably you would like to join the effort and might for example like to contribute some cool new methods for the SpreadsheetDocument class, it´s base class OpenDocument or for the other classes derived from the OpenDocument base class for other document types like Text Documents or Presentations.

 

tags:

Posted by Bernd Eilers on 07 Mar 2007  |  PermaLink |  Bookmark to Delicious To Delicious |  Digg this Digg this

Comments:

Post a Comment:
Comments are closed for this entry.
« AAWAX or How to... | Main | New: OpenOffice.org... » GullFOSS