Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

There must be a dozen different libraries out there that support reading and writing Excel documents.  Some, like POI or OpenXLS, let you manipulate Excel files directly from Java.  These libraries don't use Microsoft Excel, so they work well in mixed OS environments.  However, they don't support some key features of Excel (there are significant limitations), and their APIs don't correspond to Excel's COM API, so it can be difficult at times to figure out how use them to do even simple things. 

Other libraries, like COM4J, JCOM, and JACOB let you use Excel automation to read and create Excel files, either directly or through wrapper classes generated from COM type libraries.  This gives you full access to the complete featureset of Excel.  It also limits you to Windows.  It can be sometimes be difficult to translate from Microsoft's Visual Basic-oriented documentation to the corresponding library/wrapper in Java.  This can be particularly challenging if you aren't already up to speed on COM and the Excel APIExcel automation is also a lot slower than directly manipulating a file (process startup overhead, process-to-process communication). 

Scriptom is a COM automation library for Groovy, so it falls squarely into the second group.  In fact, Scriptom is an extension of JACOBJACOB does the heavy lifting, and Scriptom makes it groovier.

So why would you use Scriptom over one of the alternatives? 

Scriptom is intended to replicate COM scripting - as much as possible - within Java (Groovy).  It looks like COM scripting, and it feels like COM scripting.  So when you are, for instance, translating a VBA macro to its equivalent Groovy, there is very little translation involved.  You can't quite do a copy-paste, but it's close.  And when you are programming against the Microsoft documentation for the Excel API, you don't have to ask a lot of questions.  The code simply works the way it's documented. 

Additionally, Scriptom provides special support for scripting Excel.  The Scriptom library contains definitions for all the constants in the Excel type library. Scriptom also includes ExcelHelper (org.codehaus.groovy.scriptom.util.excel.ExcelHelper - whew!), which gives you an easy way to work with Excel documents in a multiprocessing (server) environment.

Are you feeling groovy yet?

Scriptom is suitable for use in low-to-medium volume tasks where Excel is available.  It is useful in batch jobs, where you aren't too concerned about execution time.  And it can be used to produce reports in Excel format for a web site (throw in a pie chart in a few lines of code), as long as you don't try to deliver more than one report every couple of seconds. \\\\- various ways to read and write Excel documents

minimalistic framework, and syntax that corresponds directly to the Microsoft documentation

  • No labels