Writing data from Java to Excel

Hi,
I am trying to writhe data from Java to an Excel Sheet by using JACOB.
This is my code :
import java.util.*;
import java.io.*;
//import cost.util.*;
import com.jacob.com.*;
import com.jacob.activeX.*;
class XLStock
     public static void main(String argv[])
          XLStock xls = new XLStock();
          xls.main2(argv);
     public void main2(String argv[])
          System.setSecurityManager(null);
          System.runFinalizersOnExit(true);
          Vector v = new Vector();
          XLSPutItem pi;
          String sheetfile = null;
          ActiveXComponent xl;
          Object xlo=null;
          Object workbooks;
          Object workbook;
          Object sheets;
          Variant vOptn = new Variant();
          vOptn.noParam();
          try
               xl = new ActiveXComponent("Excel.Application");
               xlo = xl.getObject();
               Dispatch.put(xlo, "Visible", new Variant(true));
               xl.setProperty("Visible", new Variant(true));
               workbooks = xl.getProperty("Workbooks").toDispatch();
               Variant vTemp = new Variant(argv[0]);
               workbook = Dispatch.invoke(workbooks, "Open", Dispatch.Method,
                    new Variant[] {vTemp, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn, vOptn},
                    new int[1]).toDispatch();
               sheets = Dispatch.get(workbook,"Sheets").toDispatch();
               pi = new XLSPutItem();
               if (pi.Parse("1:A1;ciao;6"))
                    v.addElement(pi);
               for (int i=0; i<v.size(); i++)
                    pi = (XLSPutItem)v.elementAt(i);
                    pi.sheet = Dispatch.invoke(sheets, "Item", Dispatch.Get, new Object[] {new Variant(pi.sheetNumber)}, new int[1]).toDispatch();
                    pi.cell = Dispatch.invoke(pi.sheet, "Range", Dispatch.Get, new Object[] {pi.cellName}, new int[1]).toDispatch();
          catch (Exception e)
               e.printStackTrace();
          pi = (XLSPutItem)v.firstElement();
          Dispatch.put(pi.cell, "Value", "ciao");
What happen is that my code always fail at this line :
xl = new ActiveXComponent("Excel.Application");
whit this error :
C:\VJWorks\JNI\jxls>java jxls.XLStock
com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatch.createInstance(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java)
at jxls.XLStock.main2(XLStock.java:53)
at jxls.XLStock.main(XLStock.java:28)
Exception in thread "main" java.util.NoSuchElementException
at java.util.Vector.firstElement(Vector.java:450)
at jxls.XLStock.main2(XLStock.java:79)
at jxls.XLStock.main(XLStock.java:28)
I task that something is wrong in my system configuration.
I work on a Win2000 platform and Office 97.
Someone knows the reason of this error and can suggest what to make.
Thanks in advance.
Antonio M.

Antonio, maybe you can post this back to the Jacob list. As an alternative to Jacob, what about Apache POI or writing the data as comma-delimited and opening the file using Runtime?
Hope that may help.
Good luck.

Similar Messages

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • Extract data from Java to Excel

    Apologies for my ignorance in this field but is it possible to extract data from a Java based application (stock charts and the like) directly into Excel? If so could someone please contact me and explain the process in very simple terms as i have no idea how Java works :o)
    Many thanks.
    Gilsey

    Actually I should qualify my "Yes" answer. It is possible for a Java application to output data to Excel (using Jakarta POI for example). Whether it is possible to persuade an existing Java application to do that depends on the application. If it has been programmed to do it, then yes. Or if it has an underlying database where it stores its data, and you have access to that database, it might be possible to extract data from the database into Excel. Otherwise the programming of the application would have to be changed.

  • Writing data from labview to excel

    Hi, currently I'm trying to get an array of data from labview into a specific excel file everytime.
    The attachment i have is a program creating a new worksheet everytime it runs. I couldn't figure out how to make it work. Anyone can help me? 
    Attachments:
    Excel Copy Example.vi ‏19 KB

    So what is the specific problem? What is it doing that is incorrect? If the problem is that it is creating a new file every time its because the first subVI is opening a spreadsheet template file. Or at least I think it is since all of the subvis are missing...
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to communicate from java to excel?

    I need to pass data from java to excel such that it'll create a report.
    It should be able to handle images also. ie.
    I have a form which contains some data.
    I need to read the data from the form and export the data - in the same format in the form - to MSexcel. I should be able to put the data in specific cells of MSexcel.
    Please help.

    example:
    out.print("Line1");
    out.print(",col2");
    out.print(",col3");
    out.println("");
    out.print("col1 - line2");
    ...

  • How to download data from spool to excel file

    Hi,
    I have requirement like....i need to download data from spool to excel file.
    Please let me know the process how to download...
    <removed by moderator>
    <removed by moderator>
    Thanks,
    Khasimsa
    Moderator message: please (re)search yourself before asking, do not assign priorities, do not offer re-ward
    locked by: Thomas Zloch on Sep 8, 2010 1:18 PM

    Hi try this way..
    *FM called that returns the Spool Request Number data into and internal table
      CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
        EXPORTING
          rqident              = p_spool                     "Spool Request Number
          first_line           = 1
        TABLES
          buffer               = it_spool_xls                            "Internal table that will have the Spool Request No data
        EXCEPTIONS
          no_such_job          = 1
          not_abap_list        = 2
          job_contains_no_data = 3
          selection_empty      = 4
          no_permission        = 5
          can_not_access       = 6
          read_error           = 7
          OTHERS               = 8.
    *To convert the spool data into excel format
      CALL FUNCTION 'SO_RAW_TO_RTF'
        TABLES
          objcont_old = it_spool_xls               "Internal table having spool data
          objcont_new = it_xls_spool.           "Int table having Excel format data converted from Spool data
    "call GUI down Load by passing  it_xls_spool
    Prabhudas

  • How to download data from itab to Excel sheet..

    Hi sap Experts,
    I develop one report to download data from itab to excel sheet.I done it perfectly.
    My doubt is in the excel sheet i need to put headings. and also at last i need to display total no.of Records.
    Please help me how to do this.
         Thanks in Advance....
    Thanks and Regards
    Siri.......................

    u can either use GUI_DOWNLOAD or the method below...just give a try
    DATA:WK_string TYPE STRING.
    DATA:Wk_EXT(4) TYPE C value '.xls'.
    DATA:WK_path TYPE STRING.
    DATA:wk_file_name type string.
    data:wk_records type sy-tfill.
    wk_file_name = 'Downloaded'.
    describe table itab lines wk_records.
    LOOP AT ITAB.
    at first.
    **Provide path
    concatenate 'C:\' wk_file_name Wk_EXT into wk_path.
    open dataset WK_path for output in text mode encoding default.
    if sy-subrc  0.
    write:'ERROR while opening dataset !!!!!!'.
    EXIT.
    endif.
    CONDENSE wk_path.
    **Heading Part
    concatenate 'Part No' 'Description'
         into wk_string separated by cl_abap_char_utilities=>horizontal_tab.
    endat.
    **Data ITAB
    CONCATENATE ITAB-MATNR itab-maktx into wk_string
         separated by cl_abap_char_utilities=>horizontal_tab.
    transfer wk_string to WK_path.
    at last.
    clear wk_string.
    Concatenate  'Records Passed:' wk_string into wk_string.
    transfer wk_string to WK_path.
    close dataset WK_path.
    endat.
    endloop.

  • How to Save Data from DataGrid to Excel Sheet?

    Hi All,
    I am trying to use Adobe Flex 3.0 for making web pages.
    I want to save the data from DataGrid and Advanced DataGrid of Adobe Flex 3.0 to Excel Sheet file. I am trying Flex Help, but didn't find answer for it.
    In the application there is a button for 'save' by pressing which the 'Save As' window should appear.
    And giving the path to the '.xls' file, the data from DataGrid should be saved on that location in .xls format.
    This is my requirement.
    If anybody knows how to do this please help.
    Thank You,
    Sharad

    Hi
    Using document.applet.saveAsCSVFile(); code you can not get data in proper format.
    For  one of my application i have stored the data from Grid to excel.
    But i am not sure about Adobe Flex 3.0, my code will work or not.
    Also you need to make the "Initialize and Script Activex Control Not marked as Safe" as enabled in your IE.
    You can share ur email. So that i can send the code. Here I am not able to paste the code.
    Thanks

  • Insert data from java to oracle object created

    Hi
    How can i insert data from java to table test with column LIST_QRY_RES_DN_MEMBER_INFO as below after create object type
    CREATE OR REPLACE TYPE QRY_RES_SERVICE_VALUES AS OBJECT (
      PARAMETER_CODE            VARCHAR2(60),
      PARAMETER_VALUE           VARCHAR2(60)
    CREATE OR REPLACE TYPE LIST_QRY_RES_SERVICE_VALUES AS TABLE OF QRY_RES_SERVICE_VALUES;
    CREATE OR REPLACE TYPE QRY_RES_OPTIONS AS OBJECT (
      SERVICE_CODE            VARCHAR2(60),
      SERVICE_VALUE           LIST_QRY_RES_SERVICE_VALUES 
    CREATE OR REPLACE TYPE LIST_QRY_RES_OPTIONS AS TABLE OF QRY_RES_OPTIONS;
    CREATE OR REPLACE TYPE QRY_RES_MEMBER_INFO AS OBJECT (
      VARIABLE_CODE            VARCHAR2(60),
      VARIABLE_VALUE           VARCHAR2(120)
    CREATE OR REPLACE TYPE LIST_QRY_RES_MEMBER_INFO AS TABLE OF QRY_RES_MEMBER_INFO;
    CREATE OR REPLACE TYPE QRY_RES_DN_MEMBER_INFO AS OBJECT (
      DN                       VARCHAR2(60),
      MEMBER_INFO              LIST_QRY_RES_MEMBER_INFO,
      OPTIONS                  LIST_QRY_RES_OPTIONS
    CREATE OR REPLACE TYPE LIST_QRY_RES_DN_MEMBER_INFO AS TABLE OF QRY_RES_DN_MEMBER_INFO;
    CREATE TABLE test(
    DN_MEMBER_INFO          LIST_QRY_RES_DN_MEMBER_INFO,
    NESTED TABLE DN_MEMBER_INFO STORE AS LIST_QRY_RES_DN_MEMBER_TAB
        (NESTED TABLE MEMBER_INFO STORE AS MEMBER_INFO_TAB,
         NESTED TABLE OPTIONS STORE AS LIST_QRY_RES_OPTIONS_TAB
            (NESTED TABLE SERVICE_VALUE STORE AS SERVICE_VALUE_TAB));

    It appears you are trying to store java objects (types) in a database rather than raw data (string, int, date types) that the object contains. If so, I don't think that ever really caught on. Most programmers store the raw data, then pull it out and populate a class. The problem with storing the object is that new versions of classes come out and your old version is stored in the database. If you just store the data, you don't have to worry about what version is in the database. You can populate the new version of the class with the same data.
    Also, others can use sql to query your data and use it for their own use independent of what you intended it for. I think most people use the (browser) based utility that comes with the database to create the tables, normalize them, set up primary keys, set up foreign keys, etc rather then run an sql statement as you did above.

  • Query Data From Oracle to Excel

    Dear all,
    Please guide me to solve.
    Regards
    Dharma

    Question's Caption is : Data From Oracle to Excel
    While you are asking :
    data in execel (windows ) move to Oracle Database table (Linux *64)Anyway, if your question is export data from Excel to Oracle then below thread may be of your interest which are saying that you have to install Dg4ODBC on Windows and use the ODBC driver there.
    When running DG4ODBC on Unix you need an ODBC driver on this Unix box which can connect to the MS Excel file. I'm not aware of any suitable driver so far that fulfills the ODBC level 3 standard required for DG4ODBC.
    So instead of using DG4ODBC, get the Windows software of DG4ODBC and install it on a Windows machine. You can then connect from your Oracle database to the Dg4ODBC listener on Windows which then spawns the DG4ODBC process. This DG4ODBC process then uses the MS Excel ODBC driver to connect to the Excel sheet.
    https://cn.forums.oracle.com/forums/thread.jspa?messageID=10466197
    For this purpose there is separate forum too : [url https://forums.oracle.com/forums/forum.jspa?forumID=63] Heterogeneous Connectivity
    Regards
    Girish Sharma

  • Copying data from Plus to Excel

    Hi,
    We are having a problem with the Plus version (10.1.2.48.18).
    When copying some data from a Plus workbook the headers that standabove columns aren't being copied. This is different then in the full version where headers are being copied.
    Is there someway to include header information in a ctrl-c/ctrl-v action? Or is this simply not possible?
    TIA.
    Jacco

    I understand you copy the data from Plus to Excel using ctrl-c/ctrl-v action directly and you can have errors. You have to export directly from plus.
    To do it, you have to click File in the menu and select Export to Excel.
    Hope this helps.

  • Copy data from datagrid to Excel

    Hi,
    I have a datagrid with lots of data.
    I want to copy the data from the datagrid and paste it in
    Excel.
    Any idea how to do this?
    Thx

    Hi
    Using document.applet.saveAsCSVFile(); code you can not get data in proper format.
    For  one of my application i have stored the data from Grid to excel.
    But i am not sure about Adobe Flex 3.0, my code will work or not.
    Also you need to make the "Initialize and Script Activex Control Not marked as Safe" as enabled in your IE.
    You can share ur email. So that i can send the code. Here I am not able to paste the code.
    Thanks

  • Exporting Data from Essbase to Excel

    Hi All,
    We are using classic planning application developed in Hyperion 11.1.2.2.
    Is there any way that we can export data from Essbase to Excel (Please note that i don't want to do it on server machine where essbase is installed, instead i want it on any client PC which is accessing Essbase)

    there are many ways you can do that, Through Excel Add-in,SmartView functions etc different.
    It depends on the requirement , if you mean to say who Essbase Data then someone else should be able to answer this.
    Thanks
    Amith

  • Post data from Toad to Excel

    I have written a query in Toad. It retrieves very huge data around 5000000 records. Now I want to export this data from Toad to Excel with faster rate. I tried to export using Save as and then gave the filename as "file.xls and enabled add include column headers. It got executed for 200000 records. But after that got a error message exceeds the limit.
    can any one please suggest me how to export the while data with faster rate from Toad to excel.
    Thanks,
    Vas.

    905508 wrote:
    hi all ,
    it's bit urgent issue. So please help me in this. it would be very helpful to me. so please share your suggestions for this.It might be urgent for you, but what makes you think everyone should drop what they're doing (their own work) as if your issue is more important than anyone elses?
    And to top that you've come onto the Oracle SQL and PL/SQL forum to ask a question about TOAD (a non-oracle product) and Excel (a non-Oracle product).
    In answer to your question however, when you go to export your data from TOAD do you have the "Display all results in grid" option checked (which is the default). If so, then as it queries all the data and tries to write it out to a CSV file, it will also try to load all that data into the grid within TOAD, which can cause it to run out of memory. Uncheck that option and TOAD will just read the data and write it to the file.

  • Export data from forms to excel

    HI
    In my application im trying to export data from forms to excel.Everything works fine.First of all im using get_file_name for selecttion of file and passing it to ole2 package as follows
    FILENAME := GET_FILE_NAME(File_Filter=> 'XLS Files (*.xls)|*.xls|',dialog_type=>SAVE_FILE);
         ARGS:=OLE2.CREATE_ARGLIST;
         oLE2.ADD_ARG(ARGS,Filename);
         OLE2.INVOKE(WORKSHEET,'SAVEAS',ARGS);
    The problem is if i select an existing file the get_file_name itself raises one message ".....file already exists Replace an existing file?"
    Similarly the excel also also raises the same message "".....file already exists Replace an existing file?".I want to suppress atleast one of them? Could anyone help for this problem?
    appreciate ur help
    THANKS

    Looks like...
    ole2.set_property( ex_app, 'DisplayAlerts', false );
    where "ex_app" variable Excel Application -
         ex_app:=     ole2.create_obj('Excel.Application');
    and more Question:
    When i close excel app - in process viewer i see "excel.exe"
    ole2.release_obj don't work :(

Maybe you are looking for

  • Problem with Restarting Tomcat 6.0.18 , Errors in Logs.

    Hello, I'm using NetBeans IDE 6.5.1. MySQL Server 5.0, mysql-connector 3.1.14, JDK 1.6 and Apache Tomcat 6.0.18. My OS is Windows XP. i'm making a Web Application and i'm trying to authenticate my Users. I tried to edit my server.xml file because i n

  • Renaming Tracks Freezes iTunes for Two Minutes

    I am not sure if this is an iTunes 8, Windows XP (I suspect so), or an iPhone 2.2 software issue. When renaming audio tracks in a playlist on iPhone 3G, for instance by adding a zero in order to correct a sequence of tracks in a playlist iTunes freez

  • Transaction Variant for Reservations MB21

    Hi As far I know there is not release strategy for reservations in order to have a control of it. We need to give MB21 to users but also wants to have control about it. Also I know that the nearest we can use is the  "movement allowed" indicator. I c

  • I need a older browser 3.5 for a FAFSA.ed.gov form online that is the required browser, can i get that?

    I need a older browser 3.5 for a FAFSA.ed.gov form online, that is the required browser, can i get that? I cant get past the sign in page due to not having the older browser, can I get the older browser?

  • FDS samples not working "send failed"

    Hi all, me again with another problem ..... I have installed FDS at the default location c:\fds2... I am having problems running the sample apps that can be accessed from the page :- http://localhost:8700/samples/ The Integrated Flex Server is runnin