views:

128

answers:

3

Hi,

I need to import some Excel spreadsheets into Java objects. I will use POI to do the task (an old version of it unfortunately). However I wonder if there is some high-level framework to do the same task but declaratively. I'm thinking in Castor and XML. The mapping Excel-Class will be stored in a resource (e.g. an XML file). Yes, I'm a lazy bones. But I don't like having lots of hard-coded POI statements when the user decides to change the input format.

Thanks

A: 

There are open source libraries that allow you to treat a spreadsheet like a database and access it via JDBC. Googling for "excel jdbc driver" should help you get started.

Rob H
+2  A: 

I like JExcelApi very much, it is simple and powerful

Thomas Einwaller
It seems equivalent to Apache POI http://poi.apache.org/Actually POI is an architectural constraint, that's why I need something over it.
Lluis Martinez
A: 

There's always the JDBC-ODBC bridge shipped with the JVM

import java.lang.*; 


public class jdbcodbc { 

   public static void main(String[] args) { 
    // Attempt to load database driver
    try
    {
     // Load Sun's jdbc-odbc driver
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    }
    catch (ClassNotFoundException cnfe) // driver not found
    {
     System.err.println ("Unable to load database driver");
     System.err.println ("Details : " + cnfe);
     System.exit(0);
    } 
    catch (InstantiationException ex)  
    {
     System.err.println ("Unable to load database driver");
     System.err.println ("Details : " + ex);
     System.exit(0);
    }
   }

}

Documentation from Sun website, JDBC-ODBC bridge

Example jdbc url potentially usable from Hibernate, for example:

jdbc:odbc:mydb;UID=me;PWD=secret

Chris Kaminski