The POI library can now be compiled as a Ruby extension, allowing the API to be called from Ruby language programs. Ruby users can therefore read and write OLE2 documents, such as Excel files with ease
The bindings are generated by compiling POI with gcj, and generating the Ruby wrapper using SWIG. The aim is the keep the POI api as-is. However, where java standard library objects are used, an effort is made to transform them smoothly into Ruby objects. Therefore, where the POI API takes an OutputStream, you can pass an IO object. Where the POI works java.util.Date or java.util.Calendar object, you can work with a Ruby Time object.
The bindings have been developed with GCC 3.4.3 and Ruby 1.8.2. You are unlikely to get correct results with versions of GCC prior to 3.4 or versions of Ruby prior to 1.8. To compile the Ruby extension, you must have GCC (compiled with java language support), Ruby development headers, and SWIG. To run, you will need Ruby (obviously!) and libgcj , presumably from the same version of GCC with which you compiled.
The POI-Ruby module sits under the POI CVS in the src/contrib/poi-ruby directory. Running make inside that directory will create a loadable ruby extention poi4r.so in the release subdirectory. Tests are in the tests/ subdirectory, and should be run from the poi-ruby directory. Please read the tests to figure out the usage.
Note that the makefile, though designed to work accross Linux/OS X/Cygwin, has been tested only on linux. There are likely to be issues on other platform; fixes gratefully accepted!
A version of poi4r.so is available here. Its been compiled on a linux box with GCC 3.4.3 and Ruby 1.8.2. It dynamically links to libgcj. No guarantees about working on any other box.
The following ruby code shows some of the things you can do with POI in Ruby
The tc_base_tests.rb file in the tests sub directory of the source distribution contains examples of simple uses of the API. The quick quide is the best place to learn HSSF API use. (Note however that none of the Drawing features are implemented in the Ruby binding.) See also the POI API documentation for more details.