Reading Excel from Java

Hello,
I would want to read excel data from Java. I do not want to register any excel drivers as I will not be able to know the file to be read before hand. Are there any better ways to solve this ?
Thanks in Advance,
Prasanna

hi prasanna
if you are using jdbc-odbc bridge I would recommend you to test the
program with excel files with varying sizes like 3,5, 12, 20 etc. There
is a some problem with the driver that it chops off some data.
For example if you have 20k excel file the driver may read in 9k chunks so you get 18k of data read and the driver ignores rest 2k.
Make sure of that it works on all sizes of input data.
bib/-

Similar Messages

  • Report in excel from java

    I'm generating report in Excel from Java.In this is it posssible to place background color upto the text in the single cell

    If you are using POI, you can set the background colour for a single cell.

  • Adapter module to read excel file -java code required for PI 7.1

    Hi PI experts,
    I am working on PI 7.1 SP 08.
    I am trying to develope an adapter module to read excel file
    http://wiki.sdn.sap.com/wiki/display/ABAP/AdapterModuleToReadExcelFilewithMultipleRowsandMultiple+Columns
    but here in this wiki , given java code is for pi 7.0 and it is using jar file from PI 7.0
    I tried with using corresponding PI 7.1 files
    com.sap.aii.af.lib.mod.jar:
    sap.comtcloggingjavaimpl.jar:
    com.sap.aii.af.svc_api.jar:
    com.sap.aii.af.cpa.svc_api.jar:
    com.sap.aii.af.ms.ifc_api.jar:
    jave program is not throwing any error in NWDS but After deploying file on server.
    i am getting this errot in communication channel
    2009-12-15 15:47:08 Information AO: Now calling the Convert Method to convert Excel to XML.
    2009-12-15 15:47:08 Error MP: exception caught with cause javax.ejb.TransactionRolledbackLocalException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBTransactionRolledbackException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file; nested exception is: javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: Bad version number in .class file
    since i am not a JAVA expert so i am unable to resolve this error
    if some one has already deployed this module for PI 7.1, then please provide me java code for PI 7.1
    Thanks
    sandeep sharma

    hi,
    please try this:
    obj = inputModuleData.getPrincipalData();
    msg = (Message) obj;
    amk = new MessageKey(msg.getMessageId(),msg.getMessageDirection());
    XMLPayload xpld = msg.getDocument();
    Workbook wb = Workbook.getWorkbook((InputStream) xpld.getInputStream());
    xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"+ "<ns0:"msgType" ""xmlns:ns0=\""nameSpace+"\">";
    Cell[] cells ;
    Cell[] cellNames ;
    cellNames = wb.getSheet(0).getRow(0);
    for(int j=1;j<wb.getSheet(0).getRows();j++)
    xmldata = xmldata+"<Record>";
    cells = wb.getSheet(0).getRow(j);
    for(int i=0;i<wb.getSheet(0).getColumns();i++)
    xmldata = xmldata"<"cellNames<i>.getContents()">"cells<i>.getContents()"</"cellNames<i>.getContents()+">";
    xmldata = xmldata+"</Record>";
    xmldata = xmldata"</ns0:"msgType+">"; 
    wb.close();
    byte byt[] = xmldata.getBytes();
    xpld.setContent(byt);
    inputModuleData.setPrincipalData(msg);
    Thanks,
    Mayank

  • Accessing excel from java code

    Hello
    our system uses reportNet to generate reports. When reports are generated in CSV format we have a problem:
    Report consists of people (can be more than one) so under name column we have same name in more than one row. BUT if more than one name is suppose to be in the CSV report then the header (column names row) is again printed.
    so for example if i requested rpeort for two names A and B (reportNet uses same template which is executed twice) then report will look like this
    Name (header - column name)
    A
    A
    A
    A
    A
    Name (header - column name)
    B
    B
    B
    B
    I want to be able to remove the second header that comes before B starts.
    so i was thinking i would be able to access this excel sheet from java. and keep record of every row. If the row changes from A to B...i delete the previous row (which would end up being the second header).
    Can this be done thru java. I havnt before accessed excel sheets from java so any pointers would be greatly appreciated.

    Hi, well CSV is not currently an Excel file, it is a Comma Separated Values
    file which can be read through Excel.
    Now, if you wish to remove the header, I would purpose that you develop an
    application that reads the CSV file, as it is mere text, and that it also reads
    another file (lets call it confirguration.txt) in which you determine the pattern
    you want to remove, then you just read your report and if a string line
    matches the pattern you defined in the configuration.txt file, then you simply
    erase it.
    And if you keep interested in reading real Excel files (xls), I would
    recommend you use POI-HSSF API from Apache.org
    http://jakarta.apache.org/poi/hssf/index.html
    Hope this helps, cya around.

  • Excel from JAVA or C++ --  Urgent -- help

    Hi
    I know it might not be possible, but i want to use couple of Financial Functions which excel provides within itself.
    Is there anyway i can use them from my JAVA or C++ code ?
    In short, would it be possible to call excel functions from JAVA or C++ code
    TIA
    Vikram

    Actually you can... In quite a few different ways. You can access any COM or OLE object in windows from within java by using the Java/COm bridge, or purchasing shrink wrapped products... The links are below:
    These people provide some very cool solutions for java. This link is specifically for excel.
    http://www.intrinsyc.com/pdfs/java-excel_bridge.pdf
    Some Resources for Java/COM...
    http://users.rcn.com/danadler/javacom/

  • Excel from Java

    Hi ,
    could any one help me in creating two excel worksheets from Java.
    I know using <%@ page contentType = "application/vnd.ms-excel" %> it will create workbook and reads data from html table .
    But I want the data from 2 html tables into 2 excel work sheets with in the same work book ..
    Thanks in Advance.

    Maybe Jakarta's POI can help you out.

  • Reading files from Java embedding.

    Dear All,
    My BPEL process has a Java embedding node, and it invokes a Java class, in which an xsl file is being read for transformation.
    I deploy the xsl files directory together with BPEL package (the jar). In the package, I put the file dir at the root level, which means the jar structure looks like the following:
    /BPEL-INF
    /META-INF
    /xsd
    /xsl
    *.wsdl
    *.bpel
    bpel.xml
    The java class is package in /BPEL-INF dir, it's supposed to read files from /xsl dir.
    My question is, how should I put the file path?
    I tried "/xsl/***.xsl" and "../xsl/***.xsl", neither works. Although "/xsl/***.xsl" worked when testing in JDeveloper, but FileNotFound after deployment.
    Thanks,
    Haibo

    I solved this issue by putting the files dir in /BPEL-INF/classes/. and use ClassLoader to read in those files.

  • Read BAPI from java

    Hi All,
    I had a requirement of reading values from BAPI through  Java. Can anybody give me links or documents on how to connect to R/3 system from java. I know this can be done through JCO API or JCA API, but i could not find enough supportive documents in SDN. So please help me out.
    Regards
    Raghu

    Dear Raghu
    You can read the BAPI values using JCO objects and I providing you wiht the sample code for the same
    public class BapiClass {
         static JCO.Client R3Client=null;
         IRepository R3repository=null;
         JCO.Function function=null;
         JCO.Table dataTable=null;
         String client = "040";
         String login = "developer";
         String pass = "sappmcoe1";
         String language = "en";
         String hostname = "hostname";
         String system = "00";
         String rfcException=null;
         String loginId=null;
    // Variables for BAPI Vaues
         String DLCode=null;
         String Status=null;
         String Icon=null;
         String ToolTip=null;
         Alerts alert;
         ArrayList dataList = new ArrayList();
         ArrayList errorList= new ArrayList();
         Iterator alertsIter=null;
         Iterator errorIter=null;
         public BapiClass(){
         public void setLoginId(String loginId) {
              this.loginId = loginId;
         public Iterator getAlertsIterator(){
              return alertsIter;
         public String getAlerts()
              int row=0;
              rfcException = "No Exception";
              try {
    //Creating Connection               
    R3Client = JCO.createClient(
                             client,
                             login,
                             pass,
                             language,
                             hostname,
                             system);
                   R3repository = JCO.createRepository("MyRepository", R3Client);
                   }catch (Exception e)
                        rfcException = "<b>Error connecting to database system</b><BR>"+e.toString();
                        return rfcException;
                try{
    //Invoking BAPI
                        IFunctionTemplate ftemplate =R3repository.getFunctionTemplate("ZSE_GETALERTS_NEW");          
                        function = new JCO.Function(ftemplate);
                        JCO.ParameterList input=function.getImportParameterList();
                        //input.setValue(loginId,"I_USERID");
                        input.setValue(loginId,"I_USERID");
                    R3Client.execute(function);
    //E_ALERTS is the BAPI Output Table Name
         dataTable = function.getExportParameterList().getTable("E_ALERTS");
                          row = dataTable.getNumRows();
                          for (int i = 0; i < dataTable.getNumRows(); i++)
                               dataTable.setRow(i);
                               DLCode = dataTable.getString("DLCODE");
                               Status=dataTable.getString("STATUS");
                               Icon = dataTable.getString("ICON");
                               ToolTip=dataTable.getString("TOOLTIP");
                                 alert=new Alerts(DLCode,Status,Icon,ToolTip);
                               dataList.add(i, alert);
                          alertsIter = dataList.iterator();
                     catch (Exception ex) {
                     ex.getStackTrace();
                     rfcException = "<b>Error connecting to database system</b><BR>"+ex.toString();
                     return rfcException;
              return rfcException;          
    Regards
    Noel

  • Using word/excel from java (client or weblogic server)

    Hi everybody,
    i want to use excel / word functionality from java in two different variants:
    -> serverside
    -> clientside
    I tried the weblogic.comc and i got serveral classes but in the remote-package i got only a utitlity-class.
    My knowlege about COM is rather bad.
    Does anybody did this bevor and
    -> can say me, if it is correct, that i only got a utility-class (so how will i use it from the client ?!)
    -> has a example for using Excel / Word from Java in bea weblogic
    -> has a example for using Excel / Word directly in a client (not via rmi)
    Thanks
    Ciao
    Sven

    Sven, This is a really bad idea. Why don't you tell me
    what your trying to do and I wil surely give you a better alternative
    JRadecki
    "Sven Roesner" <[email protected]> wrote:
    >
    Hi everybody,
    i want to use excel / word functionality from java in two different variants:
    -> serverside
    -> clientside
    I tried the weblogic.comc and i got serveral classes but in the remote-package i got only a utitlity-class.
    My knowlege about COM is rather bad.
    Does anybody did this bevor and
    -> can say me, if it is correct, that i only got a utility-class (so how will i use it from the client ?!)
    -> has a example for using Excel / Word from Java in bea weblogic
    -> has a example for using Excel / Word directly in a client (not via rmi)
    Thanks
    Ciao
    Sven

  • Read Excel from sap server HDD

    I want to read xls from path wich I see by FM RZL_READ_DIR_LOCAL (server space) and how to read xls format to itab from this path?
    ALSM_EXCEL_TO_INTERNAL_TABLE work only on local HDD (not server space)

    Hi,
    You need to use the OPEN DATASET and READ DATASET statements.
    Here is a sample, This program will upload a comma delimited file from app server, and break it up into specific fields of an ITAB.
    report ztest_0001
    no standard page heading.
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.csv'.
    data: begin of itab occurs 0,
    fld1(20) type c,
    fld2(20) type c,
    fld3(20) type c,
    end of itab.
    data: wa(2000) type c.
    start-of-selection.
    open dataset d1 for input in text mode.
    if sy-subrc = 0.
    do.
    read dataset d1 into wa.
    if sy-subrc 0.
    exit.
    endif.
    split wa at ',' into itab-fld1 itab-fld2 itab-fld3.
    append itab.
    enddo.
    endif.
    close dataset d1.
    Regards,
    Satish

  • READING XML FROM JAVA

    I am developing web services based GIS, I have XML file which was generated from Geoserver. I dont know how to link Java with XML and query XML from Java. I need help pls.
    PAI

    there are apis to parse xml using java,
    http://www.cafeconleche.org/books/xmljava/chapters/ch09s06.html
    try this link..
    regards
    Shanu

  • Invoking MS Excel from Java

    HI,
    I'm trying to create a standalone application that would need to logon in a database.If the user is a valid one, the user can then choose which table he wanted to update. All the rows of the column will be shown in an excel format. (the program will invoke Excel to show all the records in that table). From that, the user can edit the content and after saving it, data in the databse will also be updated.
    Is there any Java API that I can use to make this application possible?
    Thanks,

    Crossposted: http://forum.java.sun.com/thread.jspa?threadID=678912
    Please don't answer on this duplicate copy.
    And @OP: QUIT IT!

  • Read item from Java class and call to stored function/procedure of database

    Hi,
    I am looking solution that I was trying to find becasue of I am not expert and novice of ADF so I am getting problem to do. I am trying migrating from oracle forms to JDeveloper[ADF].
    I want to call database stored function from JSF pages by java bean class of a button press event (manually created) and after button event I have called java class which I created manually. But I can not read that values what I given into jsp page.
    question1: How can I read jsp pages items value to java class ?
    question2: How can I call to database stored function/procedure with that parameter?
    question3: How can I use return value of that stored function/procedure ?
    Please reply me .
    Thanks,
    zakir
    ===
    Edited by: Zakir Hossain on Mar 29, 2009 10:22 AM

    ---

  • Ole2 error when reading excel from form 6i

    APPLICATION OLE2.OBJ_TYPE;
    WORKBOOKS OLE2.OBJ_TYPE;
    WORKBOOK OLE2.OBJ_TYPE;
    WORKSHEETS OLE2.OBJ_TYPE;
    WORKSHEET OLE2.OBJ_TYPE;
    CELL OLE2.OBJ_TYPE;
    SROW NUMBER:=0;
    COL NUMBER:=0;
    CELLVALUE VARCHAR2(89);
    V_RC_1 VARCHAR2(1000); -- TRANSACTION DATE
    V_RC_2 VARCHAR2(1000); -- STORE #
    V_RC_3 VARCHAR2(1000); -- INVOICE #
    V_RC_4 VARCHAR2(1000); -- CASES SOLD
    V_RC_5 VARCHAR2(1000);
    V_RC_6 VARCHAR2(1000);
    ARGS OLE2.OBJ_TYPE;
    BEGIN
         :STIME := TO_CHAR(SYSDATE, 'HH:MI:SS');
    SYNCHRONIZE;
         --------------INITIATE EXCEL APPLICATION---------------------------
    APPLICATION := OLE2.CREATE_OBJ('EXCEL.APPLICATION');
    OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','TRUE');
    ----------------GET WORKBOOKS FROM EXCEL APPLICATION---------------
    WORKBOOKS := OLE2.GET_OBJ_PROPERTY(APPLICATION, 'WORKBOOKS');
    ----------------OPEN REQUIRED WORKBOOK-----------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,:VFILE);
    WORKBOOK := OLE2.GET_OBJ_PROPERTY(WORKBOOKS,'OPEN',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ----------------OPEN REQUIRED WORKSHEET---------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,1);
    WORKSHEET := OLE2.GET_OBJ_PROPERTY(WORKBOOK,'WORKSHEETS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ----------------GET CELL VALUE-------------------------------------
    LOOP
         SROW := SROW+1;
    -----------------------COLUMN1-------------------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,SROW);
    OLE2.ADD_ARG(ARGS,1);
    CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ARGS := OLE2.CREATE_ARGLIST;
    V_RC_1 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
    -----------------------COLUMN2-------------------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,SROW);
    OLE2.ADD_ARG(ARGS,2);
    CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ARGS := OLE2.CREATE_ARGLIST;
    V_RC_2 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
    -----------------------COLUMN3-------------------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,SROW);
    OLE2.ADD_ARG(ARGS,3);
    CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ARGS := OLE2.CREATE_ARGLIST;
    V_RC_3 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
    -----------------------COLUMN4-------------------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,SROW);
    OLE2.ADD_ARG(ARGS,4);
    CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ARGS := OLE2.CREATE_ARGLIST;
    V_RC_4 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
    -----------------------COLUMN5-------------------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,SROW);
    OLE2.ADD_ARG(ARGS,5);
    CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ARGS := OLE2.CREATE_ARGLIST;
    V_RC_5 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
    -----------------------COLUMN6-------------------------------------
    ARGS := OLE2.CREATE_ARGLIST;
    OLE2.ADD_ARG(ARGS,SROW);
    OLE2.ADD_ARG(ARGS,6);
    CELL := OLE2.GET_OBJ_PROPERTY(WORKSHEET,'CELLS',ARGS);
    OLE2.DESTROY_ARGLIST(ARGS);
    ARGS := OLE2.CREATE_ARGLIST;
    V_RC_6 := OLE2.GET_CHAR_PROPERTY(CELL,'TEXT');
    IF SROW >8 THEN
         EXIT;
    END IF;
    ---------------INSERT THE VALUE IN THE TABLE ---------------------
    INSERT INTO EMP VALUES(V_RC_1,V_RC_2,V_RC_3,V_RC_4,V_RC_5,V_RC_6);
    END LOOP;
    --END LOOP;
    COMMIT;
    ----------------CLOSE THE EXCEL SHEET AFTER READING--------------
    OLE2.INVOKE(APPLICATION,'QUIT');
    -----------------RELEASE ALL OBJECTS -----------------------------
    OLE2.RELEASE_OBJ(CELL);
    OLE2.RELEASE_OBJ(WORKSHEET);
    OLE2.RELEASE_OBJ(WORKBOOK);
    OLE2.RELEASE_OBJ(WORKBOOKS);
    OLE2.RELEASE_OBJ(APPLICATION);
    :MESSAGE := 'DATA INSERTED INTO THE TABLE '; SYNCHRONIZE;
    :ETIME := TO_CHAR(SYSDATE, 'HH:MI:SS');
    SYNCHRONIZE;
    END;

    Hi Kundi,
    by this time you might have solve your problem.
    If not, in your case,
    This could be you or user is closing the "Excel" application just appearing in front of there screen.
    To solve this replace the following line with the new line of code in your application:
    OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','TRUE');
    with
    OLE2.SET_PROPERTY(APPLICATION,'VISIBLE','FALSE');
    Hope this will solve the problem.
    Regards,
    Tarun
    Edited by: Tarun.Oracle on Nov 9, 2012 12:44 PM
    Edited by: Tarun.Oracle on Nov 9, 2012 12:45 PM

  • Access registry (read/write) from java

    Hi folks,
    I'm struggeling with a Java/COM bridge to read/write the registry from my java application. The documentation from Sun on this is very sparely. Would be grateful for any hints!
    Regards,
    C.H. Liljegren

    Hi Bud,
    After a long time of asking everybody and then getting no response from any of the guys from the forum .I finally decided to do it myself and guess what I do succeded in reading and writing from the registry of windows from a Java program .
    I dont have the code now its there in my office . I will send it to u tomorrow .
    But one thing I came to know that if u wanna do some thing u have to take the initiative.
    I will send u the code tomorrow.
    Take Care.
    Manoj.

Maybe you are looking for

  • Database do not start due to error 445

    Hi, We have three databases on one HP-UX 11.31 server, the DB version is 10.2.0.4, we started facing slowness in all the databases, when I tried to connect to the server it was very slow, even the sqlplus was taking very long time, when checked the a

  • Dual Monitors with Zotac DisplayPort to Dual HDMI Adaptor?

    Has anyone had the chance to try the "ZOTAC DisplayPort to Dual HDMI Adaptor" with the MacBook Pro's yet? http://www.zotacusa.com/zotac-displayport-to-dual-hdmi-adaptor.html I'm currently using a Mini DisplayPort to DisplayPort adapter to connect to

  • Change report attributes dynamically?

    Can we change the report attributes dynamically? For example, I want to dynamically set some columns to be showed or not. I plan to use a radiogroup, when I choose "Partial View", the report only show some columns; when I choose "Full View", the appl

  • PM-order: future records processing by CORUPROC in background

    Dear Colleague, CORUPROC can be run in background, but is missing some selection criteria, e.g. Order-nr, Order-type, order-date, for batchwise processing. The sisterprogram CORUPROZ is not suited for running in background, as it will provide a list

  • My A. Illustrator CS3 (v. 13.0.0) will not update to any of the latest versions

    For several weeks already, my Adobe Updater has been trying to update to the next version (13.0.1) and I kept getting the same message: Message: Installing the patch.... An error occurred during installation. The update cannot be applied to the produ