Java and Excel : POI vs JExcel API?

Hello,
I am hesitating between using the JExcel API and the Jakarta POI API to manipulate (rather simply) excel files with java.
Has anyone experimented both? What are the drawbacks and the advantages of both?
Thanks a lot,
Laetitia

Laetitia,
Hello! I've written a significant app (J2EE, EJB using WebLogic) utilizing first the POI api and then the jexcel API to produce MS excel output financial reports (for online content provider) . The application processed 80K plus lines of subscriber information, calculated monthly subscription delivery charges for 100+ publications, each with custom contracts and wrote the calculated data to 'reporting tables'. Basically a specialized datamart of sorts (I know little about 'true' data marting). App would then generate the ms excel spreadsheet reports, one per publisher, utilizing the excel API. The largest publisher report would be over 10Mb in size, containing some 40K rows of data, 30 columns wide.
I utilized the POI api first because it looked to be a more substantial product with firmer support, more developers, etc. However I soon became confused on how different modules worked, received slow feedback from the development team, and found the documentation to be horribly out of date and misleading. Additionally, the larger the generated excel file became the less stable the server would be until it would crash with memory problems. I'm not saying that the memory errors were within the POI code, but after I switched to jexcel the server crashing went away (perhaps the jexcel code is more forgiving).
I then switched to use the jexcel API and was immediately pleased. The documentation was accurate and clearer. The functionality I needed was easy to find and worked first time. When I had problems I posted my questions to the yahoo message board and was immediately helped. As an aside on the message board I'm an old internet hack with message boards and am used to stupid posts (and posters) being immediately 'flamed' and derided by those on the list 'in the know'. I was amazed by all the posts from people asking 'I just downloaded jexcel and need help' who actually got thoughtful and helpful posts, not just rude 'RTFM you @#%$$@%' replies.
Jexcel API was written by one guy but seems to be supported by several. I'd recommend it strongly - new releases come out continually and it's easy to get answers to questions on how to use it. Plus, and this is a biggy with me, the documentation is accurate and useful.
Email me for more.
-wcrighton
[email protected]

Similar Messages

  • Unable to display double values in Excel sheet using JExcel API

    Hi
    I am writing code to generate report in the form of Excel Sheet using JExcel API.
    Everything is going fine but whenever I want to put some double values in a cell it is only showing 2 decimal places. My problem is "I want to show upto five decimal places".
    Any kind of reply might help me lot.
    Thank U.

    If you enable the submit zero option, it still happens? This is a new feature on the display tabl
    #NumericZero Enhancements
    To display a numeric zero in place of an error message, you can enter #NumericZero in any of the three Replacement text fields. When you use the #NumericZero option:
    · Excel formatting for the cell is retained.
    · All calculations with dependency on the cell will compute correctly and will take the value of this cell as zero.
    · This numeric zero is for display only. When you submit, the zero value is NOT submitted back to the data source.
    You cannot set display strings for cells that contain an invalid member or dimension name (metadata error). Metadata errors produce standard descriptive error messages.
    Errors are prioritized in the following order from highest to lowest. The error message for a higher-priority error takes precedence over that for a lower-priority error.
    1. (Highest) Metadata errors
    2. #No access
    3. #Invalid/Meaningless
    4. #No data\Missing

  • Java and Excel

    I am using JTable to bring some information from the database, Is there a way that I can pass that data into an excel sheet so it can be printed in a better format.
    Thank you for your help

    Dear Friends ..................
    Some times i will get this error " [  Micro Soft  ] [ ODBC Excel Driver  ] the Micro Soft jet Data Base engine could not find the object .
    Make Sure this object is exist and that u spell it correctly................. "
    while connecting to excel . see my code ...............
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    * Name: Excel.java
    * Purpose: To demonstrate how to use ODBC and Excel to create
    * a table, insert data into it, and select it back out.
    * Version: Developed using JDK 1.3, but also works with JDK
    * 1.2.2
    * Instructions:
    * 1) Create a new Excel spreadsheet
    * 2) Create a new ODBC data source that points to this
    * spreadsheet
    * a) Go to Control Panel
    * b) Open "ODBC Data sources (32-bit) (wording may be
    * slightly different for different platforms)
    * c) Under "User DSN" tab, press "Add" button
    * d) Select the "Microsoft Excel Driver (*.xls)" and
    * press "Finish" button
    * e) Enter "Data Source Name" of "TestExcel"
    * f) Press "Select Workbook" button
    * g) Locate and select the spreadsheet you created in
    * Step 1
    * h) Unselect the "Read Only" checkbox
    * i) Press "Ok" button
    * 3) Compile and run Excel.java
    * 4) Open Excel spreadsheet and you will find a newly
    * created sheet, GOOD_DAY, with three rows of data.
    * Notes:
    * If you want to select data from a spreadsheet that was
    * NOT created via JDBC-ODBC (i.e. you entered data manually
    * into a spreadsheet and want to select it out), you must
    * reference the sheet name as "[sheetname$]".
    * When you create the table and insert the data using
    * Java, you must reference the sheet name as "sheetname".
    * Also, do not have the spreadsheet open when you are
    * running the program. You can get locking conflicts.
    public class Excel{
         public Excel(){
              setDefaults();
         private static void message(String pMessage){
              System.out.println(pMessage);
         private void setDefaults(){
              setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
              setUrl("jdbc:odbc");
              // ODBC data source named "TestExcel" defined from Control Panel
              setDataSource("TestExcel");
              setTableName("GREAT_CARS");
         public void openDatabase(){
              String file = "E:/projects/jbproject/edelapreport/classes/Excel.xls";
              //use this without setting an ODBC Data Source
              String lConnectStr = "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + file + ";DriverID=22;READONLY=false";
              //use this in the case of an existing DSN
              //String lConnectStr = getUrl()+":"+getDataSource();
              try {
                   Class.forName(getDriver());
                   gConnection = DriverManager.getConnection(lConnectStr);
              }catch (Exception e) {
                   message("Error connecting to DB: " + e.getMessage());
         private void closeDatabase(){
              try{
                   getConnection().close();
              }catch (Exception e){
                   message("closeDatabase(): "+e.getMessage());
         private void createTable(){
              message("createTable() begin");
              Statement lStat = null;
              try {
                   lStat = getConnection().createStatement();
                   lStat.execute("CREATE TABLE "+getTableName()+" ("
                   +" ID INTEGER" +" ,NAME VARCHAR" +")");
              }catch (Exception e){
                   message("createTable(): "+e.getMessage());
              message("createTable() end");
         private void doInsert(){
              message("doInsert() begin");
              Statement lStat = null;
              try {
                   lStat = getConnection().createStatement();
                   lStat.executeUpdate("INSERT INTO " +getTableName()+" VALUES (10,'Audi')");
                   lStat.executeUpdate("INSERT INTO " +getTableName()+" VALUES (20,'Mercedes')");
                   lStat.executeUpdate("INSERT INTO " +getTableName()+" VALUES (30,'BMW')");
                   lStat.executeUpdate("INSERT INTO " +getTableName()+" VALUES (40,'Audi A6')");
                   lStat.executeUpdate("INSERT INTO " +getTableName()+" VALUES (50,'Audi S6')");
                   lStat.executeUpdate("INSERT INTO " +getTableName()+" VALUES (60,'Audi 80 Quattro')");
                   lStat.close();
              }catch(Exception e){
                   message("doInsert(): "+e.getMessage());
              message("doInsert() end");
         private void dropTable(){
                   message("dropTable() begin");
                   Statement lStat = null;
                   try {
                        lStat = getConnection().createStatement();
                        lStat.execute("DROP TABLE " + getTableName());
                        lStat.close();
                   }catch(Exception e){
                        message("dropTable(): "+e.getMessage());
                   message("dropTable() end");
         private void doQuery(){
              message("doQuery() begin");
              try {
                   Statement lStat = getConnection().createStatement();
                   ResultSet lRes = lStat.executeQuery("SELECT * FROM "+getTableName());
                   ResultSetMetaData lMeta = lRes.getMetaData();
                   // print out the column headers separated by commas
                   for (int i = 1; i <= lMeta.getColumnCount(); ++i){
                        if (i > 1){
                             System.out.print(", ");
                        String lValue = lMeta.getColumnName(i);
                        System.out.print(lValue);
                   System.out.println("");
                   // print out the data separated by commas
                   while (lRes.next()){
                        for (int i=1; i<=lMeta.getColumnCount(); ++i){
                             if (i > 1){
                                  System.out.print(", ");
                             String lValue = lRes.getString(i);
                             System.out.print(lValue);
                        System.out.println("");
                   lRes.close();
                   lStat.close();
              }catch (Exception e){
                   message("doQuery(): "+e.getMessage());
              message("doQuery() end");
         private void run(){
              openDatabase();
              createTable();
              doInsert();
              doQuery();
              //dropTable();
              closeDatabase();
         public static void main(String args[]){
              message("main() begin");
              Excel lExcel = new Excel();
              lExcel.run();
              message("main() end");
              System.exit(0);
         public void setTableName (String pValue){
              gTableName = pValue;
         public String getTableName(){
              return(gTableName);
         public void setSql(String pValue){
              gSql = pValue;
         public String getSql(){
              return(gSql);
         public Connection getConnection(){
              return(gConnection);
         public String getDataSource(){
              return(gDataSource);
         public void setDataSource(String pValue){
              gDataSource = pValue;
         public void setDriver(String pValue){
              gDriver = pValue;
         public void setUrl(String pValue){
              gUrl = pValue;
         public String getDriver (){
              return (gDriver);
         public String getUrl (){
              return (gUrl);
         private Connection gConnection = null;
         private String gDataSource = null;
         private String gTableName = null;
         private String gSql = null;
         private String gDriver = null;
         private String gUrl = null;
    * Connection to Access without existing DNS
    * Connection con = null;
    * Statement st = null;
    * String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    * String path = "c:/jdk1.3/jswdk-1.0.1/examples/jsp/list/base/bd.mdb";
    * String fullConnectionString = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + path;
    * Class.forName (driver);
    * con = DriverManager.getConnection (fullConnectionString);
    * st = con.createStatement ();
    //Example for SQLServer:
    //db = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=MyServerName;Database=MyDataBase","","");
    //Example for Excel:
    //db = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/temp/test2.xls;DriverID=22;READONLY=false","","");

  • Reading and Writing large Excel file using JExcel API

    hi,
    I am using JExcelAPI for reading and writing excel file. My problem is when I read file with 10000 records and 95 columns (file size about 14MB), I got out of memory error and application is crashed. Can anyone tell me is there any way that I can read large file using JExcelAPI throug streams or in any other way. Jakarta POI is also showing this behaviour.
    Thanks and advance

    Sorry when out of memory error is occurred no stack trace is printed as application is crashed. But I will quote some lines taken from JProfiler where this problem is occurred:
              reader = new FileInputStream(new File(filePath));
              workbook = Workbook.getWorkbook(reader);
              *sheeet = workbook.getSheet(0);* // here out of memory error is occured
               JProfiler tree:
    jxl.Workbook.getWorkBook
          jxl.read.biff.File 
                 jxl.read.biff.CompoundFile.getStream
                       jxl.read.biff.CompoundFile.getBigBlockStream Thanks

  • Java and Excel sheet (hssf poi) creating back up  please help!!

    Dear friends , i have a problem i saved some data into some excel file using HSSF POI . after raeching some lines say a maximum of 1000 lines ) i have to save the EXCEL sheet as backupfile with the extention .bak and then delete the original Excel file . did any body have some idea about this . i know you guyz are gurus so please give some advise
    thanks in advance
    cheers
    harsha

    you would actually have a counter to count the number of rows you inserted into the spreadsheet..once counter hits 1000, just save it as .bak extension?

  • Reading formulars and blank cells in Excel by POI event based API

    Hello at all,
    first sorry for my english.
    I have to read Excel files using the POI event based API.
    These files contain FormularRecords, whitch values are Strings.
    I googled a lot, but I didn't found a way, to get FormularRecords as string.
    This I need, because I have to compare the position of the Cell (row, column)
    with other values.
    An other way to get these cells is reading them as StringRecord or SSTRecod.
    But there is no method .getRow() or .getColumn() for StringRecords and SSTRecords.
    My other problem:
    Some cells without a value can not be read.
    Using the BlankRecord didn't catch all of them.
    When I go to these cells and just hit Return (no value is set), then the cells can be catched.
    Can anyone give me an idea?
    It really would be very helpfull.
    And I hope my english can be understood.
    thx a lot
    eichi

    Problem is solved,
    in the datastream the FornulaRecord appears before the StringRecord.
    I take the position from the Formula and value from the String.

  • Pros and cons of jxl api and apache poi of manipulating the excel sheet.

    i want a list of pros and cons of jxl api and apache poi of manipulating the excel sheet.
    also i need to know which one is better jxl or apache poi.

    Hi Ricardo_Lorenzo,
    Whether to go for Multiserver instances or Single server, is totally a user requirement based decison. If a user has Single website, or multiple websites (of the same nature, in terms of functionality), usually the part of same domain, then they would go for Single sever installation. One single instance will handle the requests from all the websites (if there are multiple). There would not be a clustering/failover setup within ColdFusion and can use the ColdFusion Standard or Enterprise version.
    On the other hand, if a user has multiple websites, all with different functionality and have multiple applications (may or may not) running, then they can go for Multiserver installation. Each website can be configured with individual instances. Clustering can be done within ColdFusion if needed. One would need an Enterprise license of ColdFusion for the same.
    Hope this helps.
    Regards,
    Anit Kumar

  • How to use JExcel API (excel,csv)

    Hi,
    I have my java application and I want to read an excel file (.xls) using the Jexcel API to convert a part of it into csv format or a xml format (to make after a pdf file with another java library).....
    How can I do it? I need only the first steps!!! I don't know where must I start!!
    Thanks a lot

    to read Excel files using JExcel, look at the docs API first. The code you'll need looks like the following:
    Workbook workbook = Workbook.getWorkbook(new File("D:/tmp/source.xls"));
    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;
    Sheet sheet = workbook.getSheet(3);
              int cols = sheet.getColumns();
              int rows = sheet.getRows();
              Cell cell = null;
                   for (i = 1; i < rows; i++) {
                        for (i = 1; i < rows; i++) {
                          cell = sheet.getCell(j, i);
                          //System.out.println(cell.getContents());
                   }In order to generate PDF after, you can use iText or FOP.
    iText doesn't require XML. It uses simply java objects. (http://www.lowagie.com/iText/)
    If you want to generate XML file first, so use FOP. It requires XML and XSL files to generate PDF. (http://xmlgraphics.apache.org/fop/)
    Personnaly, I used the two tools (iText and FOP). I prefer iText because it simple and can generate complex PDF.
    hth

  • Difference in event handling between Java and Java API

    could anyone list the differences between Java and java-API in event handling??
    thanks,
    cheers,
    Hiru

    the event handling mechanisms in java language
    features and API (java Application Programming
    Features)features .no library can work without a
    language and no language has event handling built in.
    I am trying to compare and contrast the event
    handling mechanisms in the language and library
    combinations such as java/ java API.
    all contributions are welcome!
    thanks
    cheersSorry, I'm still not getting it. I know what Java is, and I know what I think of when I hear API. (Application Programming Interface.) The API is the aggregation of all the classes and methods you can call in Java. If we agree on that, then the event handling mechanisms in Java and its API are one and the same.
    So what do you want to know?
    %

  • Jakarta POI VS JEXCEL

    All
    I'm from Japan. My English is very poor and sorry.
    I want to operate Excel Spread sheet on Java program. I found out an information for excel spread sheet operation on Java program by using API's POI or JEXCEL.
    But I have no idea which is better. Please advice me the following topics.
    1,What's different POI and JEXCEL?
    2,What's merit and demerit POI and JEXCEL?
    My environments are
    1,Applicatoin Server :Websphere
    2,Programing Language: Java
    3,Database UDB in Z-os(MainFrame)
    My requirements are
    1,I want to pick up data from database, and create excel spread sheet on application server, and down load excel spread sheet to client.
    2,I want to update data to database created by excel spread sheets on client.
    Please advice.
    Thanks

    TechnicalDoubts wrote:
    Apache POI vs JExcel
    5.POI do not provide password capability for the spreadsheet.
    6.POI consumes lot of heap memory when we write data to excel sheet which causes outofmemory error.JExcelAPI also does not offer support for passwording a spreadsheet. Even if it did, breaking the password on a spreadsheet only takes seconds with the right tool.
    JExcelAPI, until recent versions, has been known to consume memory as well. Changes have been made to the code which greatly improves it's memory usage.
    Having used JExcelAPI for nearly 3 years now I would highly recommend using it. Here are some links to help:
    http://jexcelapi.sourceforge.net/resources/faq/
    http://tech.groups.yahoo.com/group/JExcelApi/
    The forum is active as well, myself and others are always there to help.

  • Where does workspace store the pdf and excel file ?

    Hi,
    I'm working on a Web Analysis project and I have created a dynamic web menu based on the workspace repository to improve the poor capacities of WA in terms of menu. I use the javascript API to control the WA applet from the menu.
    Now my problem is that my customer created a folder in workspace (which is translated into a sub menu of my dynamic menu), and that folder contains pdf and excel files. The function openFile which I use to open report in the applet doesn't work on pdf and excel files. So I've been looking for the files on the server, to know where they are stored, so that I could just modify the java class that generates the menu.
    I couldn't find those files on the server. Where are they ? Are they stored in the database as an xml string like the report s ? If yes then I might have a problem.
    Has anyone already done this ?
    Thanks for your help.
    Cyril

    Tomcat stores it in the work dir under $TOMCAT_HOME.
    There'll be directories like localhost%2f<urcontext>..
    As for as JSP changes being recognized, try refreshing ur browser....

  • Transfering  Access and Excel to XML

    Dear all,
    Does anybody know the classes and APIs used to transfering Access and Excel to XML?
    Kevin

    There is no single Java API that is built to translate Access and Excel data into XML. However, you can use a simple combination of APIs to accomplish this task. A direct way of doing this is to create ODBC datasources from your Access or Excel sources, use JDBC to connect to and query those datasources. From there you can use the WebRowSet to convert your ResultSet into XML. If you require more control over the formatting of the data, you'll need write something that iterates over the ResultSet data, translating the column names and values into XML. I would recommend using JDOM to build your XML documents. WebRowSet is part of the Rowset API.
    Hope this clears things for you.

  • Installing JExcel API

    Hello Everybody,
    I've posted some messages before about using JExcel API.
    Will, Finally it worked with me, and this is how it��s done; I just thought it will be helpful to be archived
    First: Download Andy Khan��s JExcel API from (Free JExcel API) :
    http://www.andykhan.com/
    Next: extract the zipped file to the C:\ drive (or any other drive)
    e.g. C:\jexcelapi
    Now you need to set the CLASSPATH to have the Jar file
    *(Windows users)* Go to: Control Panel �� System �� Environment Variables
    If you don��t yet have a system variable called CLASSPATH, create a new one and add the following path to it (including the dot and the semicolon)
    .;C:\jexcelapi\jxl.jar
    Then set JAVA_HOME to include your JDK path :
    e.g.     C:\Program Files\Java\jdk1.5.0_01
    Assigning CLASSPATH Using CMD (Dos):
    C:\jexcelapi> set CLASSPATH=.;C:\jexcelapi\jxl.jar
    Now you are done.
    To run the Demo provided with the API
    Type the following lines in the CMD window:
    C:\jexcelapi\src>javac jxl/demo/Demo.java //compile
    C:\jexcelapi\src>java jxl.demo.Demo // run
    Jxl.demo is the package provided; you need to add it to each program you create as the first line of the code
    package jxl.demo; Regards,
    MOE

    The servlet api gets installed with any web server that you install. For example if you are installing Jeeves(Java Web Server) you will find a file called servlet.jar which contains all the servlet classes. The path is ./JavaWebServer2.0/lib/servlet.jar.
    Hope that helps.
    Regards
    Jaydeep

  • Jexcel api

    Hi all,
    If any one has used jexcel api to show a drop down box in excel sheet please share the code... or any help for the same is higly appreciated.
    Thanks in advance.

    Hi all,
    I found the solution to my problem,
    For implementing <option name="x" value="0"> smiliar in html in Excel sheet
    you need to do a work around , something like writing the name in the data validation list and the value in a hidden cell
    and when the drop down is changed to select some name corresponding value will be selected by accessing the hidden cell.
    To export data to excel sheet
    using jexcel and want to show a drop down(i.e. dataValidationList), normally you will find the below code to do so -
    /* Start Code */
    //Create a blank obj with row and col num
    Blank b = new Blank(1,1);
    //Create a array list and put objs which u want as list
    ArrayList arrList = new ArrayList();
    arrList.add("DropDown1");
    arrList.add("DropDown2");
    arrList.add("DropDown3");
    //Create writable cell features obj
    WritableCellFeatures cellFeatures = new WritableCellFeatures();
    //set the array list in writable cell features
    cellFeatures.setDataValidationList(al);
    //set the cell features in the blank class
    b.setCellFeatures(cellFeatures);
    //add this blank class to writable sheet
    sheet.addCell(b);
    //write to workbook
    /* End Code */
    The above code will just create a Data Validation List with default value as blank
    to have default value as selected don't use the blank class to write to cell , use Lable instead
    Below is the code for doing this -
    /* Start of Code */
    cellFeatures = new WritableCellFeatures();
    ArrayList al = new ArrayList();
    al.add("bagpuss");
    al.add("clangers");
    al.add("ivor the engine");
    al.add("noggin the nog");
    cellFeatures.setDataValidationList(al);
    Label checkLabel = new Label(1,63,(String)al.get(1));
    checkLabel.setCellFeatures(cellFeatures);
    s1.addCell(checkLabel);
    // write to workbook
    /* End code */
    above code will create a list(DropDown) with values "bagpuss,clangers,ivor the engine,noggin the nog"
    with selected value as "clangers"

  • JExcel api jxl.jar problem

    hi,
    I just downloaded the Jexcel API from source forge. i added the jxl.jar file to my classpath and wrote a small program. But i am getting the following error.
    Read_Excel.java:4: package jxl does not exist
    import jxl.*;
    ^I am running my program through command promt only. and i have added the jar also to folder C:\Program Files\Java\jre1.6.0_04\lib\ext
    But still same problem.
    Please help.

    Opening a new command shell and working from there, would have worked, too, but hey, if you wanted to take the time to reboot, more power to you.

Maybe you are looking for

  • MB5B report missing custom fields in background execution

    Hi, I have added few fields in MB5B transaction, when I run transaction in foreground the new fields I am getting in the report output but when I run report in foreground I am not getting custom fields in the spool. Please let me know why I am not ge

  • Agents not getting SCOM UR4 Update Patch

    SCOM Agents were installed manually to 20 Domain Controllers but only 5 of them have SCOM UR4 Update Patch applied I would like to know what may be the cause of this scenario? Manage to patch the remaining DCs by running the KB2992020 for the SCOM Ag

  • Problem with page coordinates

    I'm trying to define the quads of the "Media" box of my page using the "getPageBox("Media",pageNum)" method. It returns (0,792,612,0), but when I use the addAnnot function to place an annotation at 0,0 the box is not created on the lower left. To see

  • Fcp7 not working under 10.9.5

    Is this the end for FCP7?  Is Apple forcing me to buy X?  I updated to OS 10.9.5 and FCP7 crashes upon loading.  Any suggestions?  I tried to use time machine to restore to a previous version and the "restore" button remains ghosted.  Is Time Machine

  • Every time I try to sync or use iTunes since Mavericks update it crashes

    Ever since I installed Maverick on my apple devices I cannot get any new items transferred to my ipad,iphone or watch a film on home share as Itunes just crashes when it is used.  If its just running in the back ground it will stay open for quit a wh