title: Trouble with Apache POI excel export
body: <p>I am trying to use <code>Apache POI</code> to export a <code>SQLite</code> database into an .xlsx or a xls. It seems to have no trouble getting to the table but right after that <code>XSSFWorkbook workbook = new XSSFWorkbook();</code> throws an error. It does suggest that I close <code>workbook</code> but that does not solve my problem..</p>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>import java.io.File;
  import java.io.FileOutputStream;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.sql.SQLException;
  import org.apache.poi.xssf.usermodel.XSSFCell;
  import org.apache.poi.xssf.usermodel.XSSFRow;
  import org.apache.poi.xssf.usermodel.XSSFSheet;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  public class Export 
  {
  
  public static void main(String[] args) throws Exception 
  {
  
      Connection connection = null;
      //@Override
      //public Connection getConection() throws SQLException {
  
  
          try {
              Class.forName("org.sqlite.JDBC");
  
  
               connection = DriverManager.getConnection("jdbc:sqlite:" +"C:/Test/DATABASE.db");  
              throw new SQLException(e.getMessage());
          } catch (Exception e) {
              throw new SQLException(e.getCause());
          }
  
  DriverManager.getConnection("jdbc:sqlite:" + "resources\\COPY_TRACARGODB.db");
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement
    .executeQuery("select * from BILL_LADING");
    XSSFWorkbook workbook = new XSSFWorkbook(); 
    XSSFSheet spreadsheet = workbook
    .createSheet("Tracargo EXPORTED DB");
    XSSFRow row=spreadsheet.createRow(1);
    XSSFCell cell;
    cell=row.createCell(1);
    cell.setCellValue("First Name");
    cell=row.createCell(2);
    cell.setCellValue("Last Name");
    cell=row.createCell(3);
    cell.setCellValue("Date");
    cell=row.createCell(4);
    cell.setCellValue("Time");
    cell=row.createCell(5);
    cell.setCellValue("Destination");
    int i=2;
    while(resultSet.next())
    {
       row=spreadsheet.createRow(i);
       cell=row.createCell(1);
       cell.setCellValue(resultSet.getInt("first_name"));
       cell=row.createCell(2);
       cell.setCellValue(resultSet.getString("last_name"));
       cell=row.createCell(3);
       cell.setCellValue(resultSet.getString("date"));
       cell=row.createCell(4);
       cell.setCellValue(resultSet.getString("time"));
       cell=row.createCell(5);
       cell.setCellValue(resultSet.getString("destination"));
       i++;
    }
    FileOutputStream out = new FileOutputStream(
    new File("exceldatabase.xlsx"));
    workbook.write(out);
    out.close();
   // workbook.close();
    System.out.println(
    "exceldatabase.xlsx written successfully");
  }
  }
  </code></pre>
  
  <p><strong>My Errors:</strong></p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
  at Export.main(Export.java:38)
  Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 1 more
  </code></pre>