Creating Excel Files From Java Please Help I am Lost

I am doing a project in jbuilder an using a mysql db on a remote server what i want to do is to generate reports in ms excel after executing a query for example if I search for students aged 20+ I want to generate an excel sheet with all the records ....
Does anyone knows how to do that or is there a good tutorial on the web that explains this issue
Your help is appreciated many thanks...........

Spooling the data in a comma "," delimited file is actually a good option. I have used this a couple of times and works like a charm. Spoooling the file is easy because it is a normal text file. Do remember to name the file as <something>.csv - files with this extension is linked to Excel in Windows.

Similar Messages

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

  • Help for writing to excel file from Java Program

    Hi,
    I am new to Java and Java API. I need to write to some specific cells of an excel file from a Java Program. Please anyone help me or give some directions.
    Thanks,
    Reet

    Hi,
    I saw an example while searching in google about importing jxl.*. Could you direct me how I can import this package as java does not have it. I heard that jxl is much easier that POI although I am not new to both of them.
    Thanks,
    Priya

  • Create an excel file from java

    I am using Jakarta's POI to create an excel file from MySql. The POI works well when a samll amount of data was written from MySql (created .xls file less than 3500KB). The problem is when a large amount of data need to be written to an excel file, java.lang.OutOfMemoryError Exception in thread "main" appears. In my project, I really need to have a large amount of data to be wriiten ton excel file. Do somebody has good solution for it?
    Thanks

    What about using some text files like csv
    (comma-separated value) file? It is plain text but
    Excel (and other spreadsheet programs) will be able to
    read it.
    But then there will be no formatting and bells and
    whistles. It was just an idea.Excel will also read HTML <TABLE>'s, with full formatting. There are some extra tags for numeric formatting, also. Just create an HTML table, and save to a file with .xls extension, e.g.:
    <TABLE>
    <TR bgcolor="#00FF7F">
    <TH>Agency ID</TH>
    <TH>POS ID</TH>
    <TH>Machine Serial</TH>
    <TH>Disk Serial</TH>
    <TH>MAC ID</TH>
    <TH>System Manufacturer</TH>
    <TH>Machine Type</TH>
    <TH>BIOS Manufacturer</TH>
    <TH>BIOS Version</TH>
    <TH>BIOS Date</TH>
    </TR>
    <TR bgcolor="#9ACD32">
    <TD>1000</TD>
    <TD>1069</TD>
    <TD STYLE='vnd.ms-excel.numberformat:@'>US215199248</TD>
    <TD STYLE='vnd.ms-excel.numberformat:@'>5C5AE88F3</TD>
    <TD STYLE='vnd.ms-excel.numberformat:@'>000423155334</TD>
    <TD>Hewlett-Packard</TD>
    <TD>Desktop</TD>
    <TD>American Megatrends Inc.</TD>
    <TD>JA.01.03US</TD>
    <TD>07/19/2001</TD>
    </TR>
    </TABLE>

  • Problem in Creating excel file from internal table

    Hi Experts,
                here iam having a proble with creating an excel file from an internal table which is having around 15 records, when iam generating an excel file, its getting only upto 255 chars, after that its breaking and new record is being started in the next row. how should i get all the contents in one row of the excel or may be extended to the next line , how to resolve this issue, can anyone give me some idea or sample code.
    Thanks & Regards,
    poorna

    ur downloading to excel using a single field...then it will download only 255 chars....may be from internla table u can download the fields and the excel sheet gets downloaded with data....check below code....
    *& Report  ZETA_EXCEL_DOWNLOAD_CLIPBOARD                               *
    report  zeta_excel_download_clipboard           .
    include ole2incl.
    data:  w_cell1     type ole2_object,
           w_cell2     type ole2_object.
    *--- Ole data Declarations
    data: h_excel     type ole2_object,        " Excel object
          h_mapl      type ole2_object,        " list of workbooks
          h_map       type ole2_object,        " workbook
          h_zl        type ole2_object,        " cell
          h_f         type ole2_object,        " font
          gs_interior type ole2_object,        " Pattern
          worksheet   type ole2_object,
          h_cell      type ole2_object,
          h_cell1     type ole2_object,
          range       type ole2_object,
          h_sheet2    type ole2_object,
          h_sheet3    type ole2_object,
          gs_font     type ole2_object,
          flg_stop(1) type c.
              Internal table Declaration
    data: begin of t_excel occurs 0,
    vkorg(20) type c, "Sales Org
    vbtyp(20) type c, "Document Category
    auart(20) type c, "Document Type
    ernam(20) type c, "Created By
    vbeln(20) type c, "Document Number
    posnr(20) type c, "Item Number
    erdat(20) type c, "Created Date
    vdatu(20) type c, "Header Requested Delivery Date
    reqdat(20) type c, "Request date
    condat(20) type c, "Confirm date
    lifsk(20) type c, "Header Block
    txt30(30) type c, "Order User Status Description
    lifsp(20) type c, "Line Block
    dispo(20) type c, "MRP Controller
    dsnam(20) type c, "MRP Controller Description
    vmsta(20) type c, "Material Sales Status
    kunnr(20) type c, "Sold To
    cname(35) type c, "Sold To Name
    regio(20) type c, "State
    cufd(10) type c, "CUD
    bstnk(20) type c, "PO#
    bsark(20) type c, "Ordering Method
    matnr(20) type c, "Material
    maktx(35) type c, "Material Description
    t200(20) type c, "T200
    vtext(20) type c, "T200 Description
    matkl(20) type c, "Material Group
    zzbomind(7) type c, "BOM Indicator
    ostat(20) type c, "Order Status
    cmgst(20) type c, "CRD
    inco1(20) type c, "Incoterms
    oqty(20) type c, "Order Quantity
    pqty(20) type c, "Open Quantity
    unit(20) type c, "UOM
    onet(20) type c, "Order Value
    pnet(20) type c, "Open Value
    curr(20) type c, "Currency key
    so_bezei like tvkbt-bezei,"Sales Office
    sg_bezei like tvgrt-bezei,"Sales Group
    bname(20) type c, "Ordering Party
    contact(20) type c, "Contact Name
    telf1(20) type c, "Contact telf1
    reqqty(20) type c, "Item Request qty
    reqval(20) type c, "Item Request value
    conqty(20) type c, "Item Confirm qty
    conval(20) type c, "Item Confirm value
    zzrev(02) type c, "Revenue recognition acceptance
    bezei(20) type c, "Revenue recognition text
    vgbel(20) type c, "Reference Order for RETURNS
    0008text(255) type c, "Internal Order Comment Text
    end of t_excel.
    data: t_excel_bckord like t_excel occurs 0 with header line,
          t_excel_bcklog like t_excel occurs 0 with header line,
          t_excel_blkord like t_excel occurs 0 with header line.
      types: data1(1500) type c,
             ty          type table of data1.
      data:  it          type ty with header line,
    it_2          type ty with header line,
    it_3          type ty with header line,
             rec         type sy-tfill,
             deli(1)     type c,
             l_amt(18)   type c.
    data: begin of hex,
             tab type x,
            end of hex.
      field-symbols: <fs>      .
      constants cns_09(2) type n value 09.
      assign deli to <fs> type 'X'.
      hex-tab = cns_09.
      <fs> = hex-tab.
    data gv_sheet_name(20) type c .
    M A C R O Declaration
    define ole_check_error.
      if &1 ne 0.
        message e001(zz) with &1.
        exit.
      endif.
    end-of-definition.
    t_excel_bckord-vkorg = 'ABC'.
    t_excel_bckord-vbtyp = 'DEF'.
    t_excel_bckord-auart = 'GHI'.
    t_excel_bckord-ernam = 'JKL'.
    t_excel_bckord-vbeln = 'MNO'.
    t_excel_bckord-0008text = 'XYZ'.
    append t_excel_bckord.
    t_excel_bckord-vkorg = 'ABC1'.
    t_excel_bckord-vbtyp = 'DEF1'.
    t_excel_bckord-auart = 'GHI1'.
    t_excel_bckord-ernam = 'JKL1'.
    t_excel_bckord-vbeln = 'MNO1'.
    t_excel_bckord-0008text = 'XYZ1'.
    append t_excel_bckord.
    t_excel_bckord-vkorg = 'ABC2'.
    t_excel_bckord-vbtyp = 'DEF2'.
    t_excel_bckord-auart = 'GHI2'.
    t_excel_bckord-ernam = 'JKL2'.
    t_excel_bckord-vbeln = 'MNO2'.
    t_excel_bckord-0008text = 'XYZ2'.
    append t_excel_bckord.
    t_excel_bcklog-vkorg = 'ABC'.
    t_excel_bcklog-vbtyp = 'DEF'.
    t_excel_bcklog-auart = 'GHI'.
    t_excel_bcklog-ernam = 'JKL'.
    t_excel_bcklog-vbeln = 'MNO'.
    t_excel_bcklog-0008text = 'XYZ'.
    append t_excel_bcklog.
    t_excel_bcklog-vkorg = 'ABC1'.
    t_excel_bcklog-vbtyp = 'DEF1'.
    t_excel_bcklog-auart = 'GHI1'.
    t_excel_bcklog-ernam = 'JKL1'.
    t_excel_bcklog-vbeln = 'MNO1'.
    t_excel_bcklog-0008text = 'XYZ1'.
    append t_excel_bcklog.
    t_excel_bcklog-vkorg = 'ABC2'.
    t_excel_bcklog-vbtyp = 'DEF2'.
    t_excel_bcklog-auart = 'GHI2'.
    t_excel_bcklog-ernam = 'JKL2'.
    t_excel_bcklog-vbeln = 'MNO2'.
    t_excel_bcklog-0008text = 'XYZ2'.
    append t_excel_bcklog.
    t_excel_bcklog-vkorg = 'ABC3'.
    t_excel_bcklog-vbtyp = 'DEF3'..
    t_excel_bcklog-auart = 'GHI3'.
    t_excel_bcklog-ernam = 'JKL3'.
    t_excel_bcklog-vbeln = 'MNO3'.
    t_excel_bcklog-0008text = 'XYZ3'.
    append t_excel_bcklog.
    t_excel_blkord-vkorg = 'ABC'.
    t_excel_blkord-vbtyp = 'DEF'.
    t_excel_blkord-auart = 'GHI'.
    t_excel_blkord-ernam = 'JKL'.
    t_excel_blkord-vbeln = 'MNO'.
    t_excel_blkord-0008text = 'XYZ'.
    append t_excel_blkord.
    t_excel_blkord-vkorg = 'ABC1'.
    t_excel_blkord-vbtyp = 'DEF1'.
    t_excel_blkord-auart = 'GHI1'.
    t_excel_blkord-ernam = 'JKL1'.
    t_excel_blkord-vbeln = 'MNO1'.
    t_excel_blkord-0008text = 'XYZ1'.
    append t_excel_blkord.
    t_excel_blkord-vkorg = 'ABC2'.
    t_excel_blkord-vbtyp = 'DEF2'.
    t_excel_blkord-auart = 'GHI2'.
    t_excel_blkord-ernam = 'JKL2'.
    t_excel_blkord-vbeln = 'MNO2'.
    t_excel_blkord-0008text = 'XYZ2'.
    append t_excel_blkord.
    t_excel_blkord-vkorg = 'ABC3'.
    t_excel_blkord-vbtyp = 'DEF3'..
    t_excel_blkord-auart = 'GHI3'.
    t_excel_blkord-ernam = 'JKL3'.
    t_excel_blkord-vbeln = 'MNO3'.
    t_excel_blkord-0008text = 'XYZ3'.
    append t_excel_blkord.
    t_excel_blkord-vkorg = 'ABC4'.
    t_excel_blkord-vbtyp = 'DEF4'..
    t_excel_blkord-auart = 'GHI4'.
    t_excel_blkord-ernam = 'JKL4'.
    t_excel_blkord-vbeln = 'MNO4'.
    t_excel_blkord-0008text = 'XYZ4'.
    append t_excel_blkord.
    loop at t_excel_bckord.
    concatenate
    t_excel_bckord-vkorg
    t_excel_bckord-vbtyp
    t_excel_bckord-auart
    t_excel_bckord-ernam
    t_excel_bckord-vbeln
    t_excel_bckord-posnr
    t_excel_bckord-erdat
    t_excel_bckord-vdatu
    t_excel_bckord-reqdat
    t_excel_bckord-condat
    t_excel_bckord-lifsk
    t_excel_bckord-txt30
    t_excel_bckord-lifsp
    t_excel_bckord-dispo
    t_excel_bckord-dsnam
    t_excel_bckord-vmsta
    t_excel_bckord-kunnr
    t_excel_bckord-cname
    t_excel_bckord-regio
    t_excel_bckord-cufd
    t_excel_bckord-bstnk
    t_excel_bckord-bsark
    t_excel_bckord-matnr
    t_excel_bckord-maktx
    t_excel_bckord-t200
    t_excel_bckord-vtext
    t_excel_bckord-matkl
    t_excel_bckord-zzbomind
    t_excel_bckord-ostat
    t_excel_bckord-cmgst
    t_excel_bckord-inco1
    t_excel_bckord-oqty
    t_excel_bckord-pqty
    t_excel_bckord-unit
    t_excel_bckord-onet
    t_excel_bckord-pnet
    t_excel_bckord-curr
    t_excel_bckord-so_bezei
    t_excel_bckord-sg_bezei
    t_excel_bckord-bname
    t_excel_bckord-contact
    t_excel_bckord-telf1
    t_excel_bckord-reqqty
    t_excel_bckord-reqval
    t_excel_bckord-conqty
    t_excel_bckord-conval
    t_excel_bckord-zzrev
    t_excel_bckord-bezei
    t_excel_bckord-vgbel
    t_excel_bckord-0008text
    into it
    separated by deli.
    append it.
        clear it.
    endloop.
    loop at t_excel_bcklog.
    concatenate
    t_excel_bcklog-vkorg
    t_excel_bcklog-vbtyp
    t_excel_bcklog-auart
    t_excel_bcklog-ernam
    t_excel_bcklog-vbeln
    t_excel_bcklog-posnr
    t_excel_bcklog-erdat
    t_excel_bcklog-vdatu
    t_excel_bcklog-reqdat
    t_excel_bcklog-condat
    t_excel_bcklog-lifsk
    t_excel_bcklog-txt30
    t_excel_bcklog-lifsp
    t_excel_bcklog-dispo
    t_excel_bcklog-dsnam
    t_excel_bcklog-vmsta
    t_excel_bcklog-kunnr
    t_excel_bcklog-cname
    t_excel_bcklog-regio
    t_excel_bcklog-cufd
    t_excel_bcklog-bstnk
    t_excel_bcklog-bsark
    t_excel_bcklog-matnr
    t_excel_bcklog-maktx
    t_excel_bcklog-t200
    t_excel_bcklog-vtext
    t_excel_bcklog-matkl
    t_excel_bcklog-zzbomind
    t_excel_bcklog-ostat
    t_excel_bcklog-cmgst
    t_excel_bcklog-inco1
    t_excel_bcklog-oqty
    t_excel_bcklog-pqty
    t_excel_bcklog-unit
    t_excel_bcklog-onet
    t_excel_bcklog-pnet
    t_excel_bcklog-curr
    t_excel_bcklog-so_bezei
    t_excel_bcklog-sg_bezei
    t_excel_bcklog-bname
    t_excel_bcklog-contact
    t_excel_bcklog-telf1
    t_excel_bcklog-reqqty
    t_excel_bcklog-reqval
    t_excel_bcklog-conqty
    t_excel_bcklog-conval
    t_excel_bcklog-zzrev
    t_excel_bcklog-bezei
    t_excel_bcklog-vgbel
    t_excel_bcklog-0008text
    into it_2
    separated by deli.
    append it_2.
        clear it_2.
    endloop.
    loop at t_excel_blkord.
    concatenate
    t_excel_blkord-vkorg
    t_excel_blkord-vbtyp
    t_excel_blkord-auart
    t_excel_blkord-ernam
    t_excel_blkord-vbeln
    t_excel_blkord-posnr
    t_excel_blkord-erdat
    t_excel_blkord-vdatu
    t_excel_blkord-reqdat
    t_excel_blkord-condat
    t_excel_blkord-lifsk
    t_excel_blkord-txt30
    t_excel_blkord-lifsp
    t_excel_blkord-dispo
    t_excel_blkord-dsnam
    t_excel_blkord-vmsta
    t_excel_blkord-kunnr
    t_excel_blkord-cname
    t_excel_blkord-regio
    t_excel_blkord-cufd
    t_excel_blkord-bstnk
    t_excel_blkord-bsark
    t_excel_blkord-matnr
    t_excel_blkord-maktx
    t_excel_blkord-t200
    t_excel_blkord-vtext
    t_excel_blkord-matkl
    t_excel_blkord-zzbomind
    t_excel_blkord-ostat
    t_excel_blkord-cmgst
    t_excel_blkord-inco1
    t_excel_blkord-oqty
    t_excel_blkord-pqty
    t_excel_blkord-unit
    t_excel_blkord-onet
    t_excel_blkord-pnet
    t_excel_blkord-curr
    t_excel_blkord-so_bezei
    t_excel_blkord-sg_bezei
    t_excel_blkord-bname
    t_excel_blkord-contact
    t_excel_blkord-telf1
    t_excel_blkord-reqqty
    t_excel_blkord-reqval
    t_excel_blkord-conqty
    t_excel_blkord-conval
    t_excel_blkord-zzrev
    t_excel_blkord-bezei
    t_excel_blkord-vgbel
    t_excel_blkord-0008text
    into it_3
    separated by deli.
    append it_3.
        clear it_3.
    endloop.
      if h_excel-header = space or h_excel-handle = -1.
    start Excel
        create object h_excel 'EXCEL.APPLICATION'.
      endif.
    PERFORM err_hdl.
    *--- get list of workbooks, initially empty
      call method of h_excel 'Workbooks' = h_mapl.
    PERFORM err_hdl.
      set property of h_excel 'Visible' = 1.
    add a new workbook
      call method of h_mapl 'Add' = h_map.
    PERFORM err_hdl.
    *GV_SHEET_NAME = '1st SHEET'.
    gv_sheet_name = 'Back Orders'.
      get property of  h_excel 'ACTIVESHEET' = worksheet.
    set property of worksheet 'Name' = gv_sheet_name .
    *--Formatting the area of additional data 1 and doing the BOLD
    call method of h_excel 'Cells' = w_cell1
    exporting
    #1 = 1
    #2 = 1.
    call method of h_excel 'Cells' = w_cell2
    exporting
    #1 = 1
    #2 = 50.
    call method of h_excel 'Range' = h_cell
    exporting
    #1 = w_cell1
    #2 = w_cell2.
    *CALL METHOD OF gs_cells 'Select' .
    get property of h_cell 'Font' = gs_font .
    set property of gs_font 'Bold' = 1 .
            data l_rc type i.
      call method cl_gui_frontend_services=>clipboard_export
        importing
          data                 = it[]
        changing
          rc                   = l_rc
        exceptions
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          others               = 4.
      call method of h_excel 'Cells' = w_cell1
        exporting
          #1 = 1
          #2 = 1.
      call method of h_excel 'Cells' = w_cell2
        exporting
          #1 = 1
          #2 = 1.
    PERFORM err_hdl.
       call method of h_excel 'Range' = range
        exporting
          #1 = w_cell1
          #2 = w_cell2.
      call method of range 'Select'.
    PERFORM err_hdl.
      call method of worksheet 'Paste'.
    PERFORM err_hdl.
    CALL METHOD OF h_excel 'QUIT'.
    *GV_SHEET_NAME = '2ND SHEET'.
    gv_sheet_name = 'Backlog'.
    get property of h_excel 'Sheets' = h_sheet2 .
      call method of h_sheet2 'Add' = h_map.
    set property of h_map 'Name' = gv_sheet_name .
      get property of  h_excel 'ACTIVESHEET' = worksheet.
    *--Formatting the area of additional data 1 and doing the BOLD
    call method of h_excel 'Cells' = w_cell1
    exporting
    #1 = 1
    #2 = 1.
    call method of h_excel 'Cells' = w_cell2
    exporting
    #1 = 1
    #2 = 50.
    call method of h_excel 'Range' = h_cell
    exporting
    #1 = w_cell1
    #2 = w_cell2.
    get property of h_cell 'Font' = gs_font .
    set property of gs_font 'Bold' = 1 .
      call method cl_gui_frontend_services=>clipboard_export
        importing
          data                 = it_2[]
        changing
          rc                   = l_rc
        exceptions
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          others               = 4.
      call method of h_excel 'Cells' = w_cell1
        exporting
          #1 = 1
          #2 = 1.
      call method of h_excel 'Cells' = w_cell2
        exporting
          #1 = 1
          #2 = 1.
    PERFORM err_hdl.
       call method of h_excel 'Range' = range
        exporting
          #1 = w_cell1
          #2 = w_cell2.
      call method of range 'Select'.
    PERFORM err_hdl.
      call method of worksheet 'Paste'.
    *GV_SHEET_NAME = '3rd SHEET'.
    gv_sheet_name = 'Blocked Orders'.
    get property of h_excel 'Sheets' = h_sheet3 .
      call method of h_sheet3 'Add' = h_map.
    set property of h_map 'Name' = gv_sheet_name .
      get property of  h_excel 'ACTIVESHEET' = worksheet.
    *--Formatting the area of additional data 1 and doing the BOLD
    call method of h_excel 'Cells' = w_cell1
    exporting
    #1 = 1
    #2 = 1.
    call method of h_excel 'Cells' = w_cell2
    exporting
    #1 = 1
    #2 = 50.
    call method of h_excel 'Range' = h_cell
    exporting
    #1 = w_cell1
    #2 = w_cell2.
    get property of h_cell 'Font' = gs_font .
    set property of gs_font 'Bold' = 1 .
      call method cl_gui_frontend_services=>clipboard_export
        importing
          data                 = it_3[]
        changing
          rc                   = l_rc
        exceptions
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          others               = 4.
      call method of h_excel 'Cells' = w_cell1
        exporting
          #1 = 1
          #2 = 1.
      call method of h_excel 'Cells' = w_cell2
        exporting
          #1 = 1
          #2 = 1.
    PERFORM err_hdl.
       call method of h_excel 'Range' = range
        exporting
          #1 = w_cell1
          #2 = w_cell2.
      call method of range 'Select'.
    PERFORM err_hdl.
      call method of worksheet 'Paste'.
    *--- disconnect from Excel
      free object h_zl.
      free object h_mapl.
      free object h_map.
      free object h_excel.

  • Excel File is corrupt, Please help

    I have an excel file that has recently become corrupt. I was working on this file from last 3 years without any problem. It is helpful if someone know easy and quick method to recover data from it.  
    All other files are working fine. 

    Hi Peter,
    It looks your file is corrupt, try to repair the corrupted file manually:
    On the File tab, click Open.
    In the Open dialog box, select the corrupted workbook that you want to open.
    Click the arrow next to the Open button, and then click Open and Repair.
    To recover as much of the workbook data as possible, click Repair.
    P.S: It might possible that you have mailed this workbook to someone previously. If file is there then download it.
    Good Luck!!!

  • Create XML file from java

    Hi all i am working to create a XML file using java can any one show me some sample code how to do so

    All I suggested was to insert a single line ("X.serialize(root);") into your code. Anyway, here's a ready-to-compile source code based on yours. This code utilizes the Xerces-J class library.import java.io.File;
    import java.io.FileWriter;
    import org.apache.xerces.dom.DocumentImpl;
    import org.apache.xml.serialize.OutputFormat;
    import org.apache.xml.serialize.XMLSerializer;
    import org.w3c.dom.Element;
    public class Test {
      public static void main(String[] arguments) {
        FileWriter out;
        DocumentImpl d;
        Element root;
        XMLSerializer X;
        try {
          System.out.println(" creatin ");
          File fos = new File("xsr.xml");
          out = new FileWriter("xsr.xml");
          System.out.println("created File .." + fos.getName());
          out.flush();
          d = new DocumentImpl();
          System.out.println("create root");
          root = d.createElement("abc");
          System.out.println("creating element");
          d.insertBefore(root, null);
          //out.write(d.createAttribute(""));
          OutputFormat o = new OutputFormat(d);
          System.out.println("Output format...");
          o.setIndent(5);
          o.setIndenting(true);
          o.setDoctype("lab1.dtd", "lab1.dtd");
          o.setDoctype("name of dtd file", "name of dtd file");
          X = new XMLSerializer(o);
          X.setOutputCharStream(out);
          X.serialize(root);
          out.flush();
          out.close();
        catch (Exception e1){
          e1.printStackTrace();
    }

  • Creating .jnlp files from .java files

    Last resort: Ask on the forums. I'm having a lot of trouble creating .jnlp files with only a .java file. For some reason if I do create project, the project does not run correctly, but when I make the file and run the file alone, it works perfectly fine. Most of the tutorials that I have read online ask me to do weird manifest .class stuff (in order to make JAR files, which i have failed to do even after attempting to make one after 3 hours). And still, when it comes to make the .jnlp file, I don't quite understand anything. When putting it on the web, I'm planning not to use php (html is in my mind right now), and I have aborted every single attempt at making the JAR files and whatnot.
    At this point, I'm not asking for anything other than a link to a tutorial that actually works, because all that I have tried (for the JAR files, especially) have been giving me errors. By the way, one really bothersome output that comes up is the "illegal option: j" when I use the Tool for the JAR file, and I have no idea what that means--I google it and find nothing. The .java itself extends JPanel, so it isn't really an applet.
    How to: Run an Applet
    Create an Applet Class by clicking File > New > File > File Type > Java Classes > Applet Class.
    Enter a name and path for the applet and click Finish.
    Build the file by pressing F7.
    Create an Applet HTML file by clicking File > New > File > File Type > Other > HTML Applet.
    Enter a name and path for the applet and click Finish.
    Open the HTML file in JCreator and modify the applet tag to match the name of the applet class.
    Open the Project Settings window and select the HTML file as the Run parameter.
    Click the Run Project button.It isn't really a code, but I tried doing this and the HTML Applet said code = ".class" Again, I don't have a class for the file. And when you do the "File > New > File > File Type > Java Classes > Applet Class," you get the .java file and a folder that says "components, with two classes in it. I was completely befuddled.

    http://forum.java.sun.com/thread.jspa?messageID=9783924

  • What the best way to create XML files from JAVA application?

    Hi to all,
    I need to edit and to create new filex in format of xml. I know to parse, but what would be the best way to do:
    1. - Create new file, create like simle text file, or there is some clases that know to do it in more simple way
    2.a - Edit XML file, to take some data and add it to the XML in the place I want to.
    2.b - Also Edit, but not to add fields, just update some of them.
    Code examples or links to samples woul be welcomed.
    Best regards, Nick.

    I have tried working with XML directly using the Java classes but this was a pain. I then looked at DOM4J and JDOM and found JDOM easier to use.

  • Problem with reading files from folders - please help

    Hi!
    I have 2 folders (folder1 and folder2) on 2 different locations. Now i will say few things about my program.
    First folder is input folder. Different applications generate XML files and put them inside folder1.
    Then i have my application which i use to manipulate with those folders. Basically, i have 2 threads. One is checking if there are files in folder1 and other thread is moving manipulated files from folder1 to folder2.
    I face this problem. XML files are much faster generated then manipulated. Example: for every 3 incoming files into folder1 i have 1 manipulated and stored file into folder2. This way i face problem that some older files are never manipulated, they are stuck in folder1 basically forever.
    Could someone help me to solve this problem? I do not know how to select files form folder1 ordered by "date modified time".
    Tnx for your time and help!

    Do not crosspost! I'll lock this thread.

  • How to create .exe files from Java class files?

    I'm new to Java and I just wonder if it is possible to make executable files out of Java class files. I've checked the Java online help and several search engines, but I still couldn't find anything about that. Is it possible to do so? If not, why not?
    Thanx a lot for any help.

    I don't remember if there is a program that converts the class file,
    but I do know that there are a few that either convert the class file,
    or the .java file. You might try searching for ".java to .exe" in the
    search engine and seeing what that pulls up.

  • Creating exe files from java files

    Hi all.
    I've created a Java GUI file and I want to create an exe file of it, so i can just double click on the icon and opens up..
    Anyway as to how i could do this?
    Hope to hear from anyone. Would be a great help
    Kind Regards,
    Raheal

    http://forum.java.sun.com/thread.jspa?messageID=9783924

  • Importing JPEG files from powerpoint - Please help I'm on a deadline!

    I've been importing slides from powerpoint (saved as JPEG files) into imovie (there are 7 in all). I've done this without a problem. I decided I wanted to change some of the words so I went into my original powerpoint file, did my changes, and saved the slides as JPEG files as usual. For some reason now when I import each of the slides they're huge so the words are cut off. I've been trying to reduce the font size but now it's getting hard to read! Does anyone have any ideas as to why I'm suddenly having problems and how I can fix this? I need to ship this out today by 5pm EST.
    Thanks!

    Thank you for your help!
    Would you know why it's now importing these files in such a way that I"m not able to change the length of the slide? (it's importing it for 2 seconds almost as if it's a movie file - it has a little play button on the top which looks different from my other files)

  • Creating Picture file from text. HELP

    If someone could point me in the right direction or give me a example; that would be Great! Thank you, in advance.
    This is the case... I want to create a picture file based on the text file being read, either bipmap, jpg or any widely used picture file format. What the program will do is read a file and translate the file into a picture. Based on the parameters in the file the program will create a picture the picture will be both text and other symbols.
    Thank you.

    With javax.imageio it is very easy to save a BufferedImage, so the problem really is how to render text on a BufferedImage. Here's a short sample how one line of text can be saved into a .png image. Unfortunately laying out text, rendering multiple lines, deciding where the line should be broken etc is a little more complicated than rendering just a short bit of text, but there's a lesson on it in the Java2D tutorial at http://java.sun.com/docs/books/tutorial/2d/textandfonts/linebreakmeasure.html
    and further information in the 2D graphics guide at http://java.sun.com/j2se/1.4.2/docs/guide/2d/spec/j2d-fonts.html#wp74623
    It might also be possible to get a gui component like JTextArea to handle the text layout and rendering for you.import java.awt.Color;
    import java.awt.Font;
    import java.awt.font.FontRenderContext;
    import java.awt.font.GlyphVector;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.awt.Rectangle;
    import java.awt.RenderingHints;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class Text2PNG {
        public static void main(String[] args) throws Exception {
         // The text to render
         String text = "ABCDEFG abcdefg";
         // The font to use
         Font f = new Font("Dialog", Font.PLAIN, 24);
         // Find out the bounds of the rendered text when fractional metrics and
         // antialiasing is used:
         FontRenderContext cntxt = new FontRenderContext(null, true, true);
         GlyphVector glvec = f.createGlyphVector(cntxt, text);
         Rectangle bounds = glvec.getPixelBounds(cntxt, 0, 0);
         // Set up an image that has the same size as the rendered text:
         BufferedImage image = new BufferedImage(bounds.width, bounds.height,
              BufferedImage.TYPE_INT_RGB);
         Graphics2D g2d = (Graphics2D) image.getGraphics();
         g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
         g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
         // Fill the background of the image with white:
         g2d.setColor(Color.WHITE);
         g2d.fillRect(0, 0, image.getWidth(), image.getHeight());
         // Render the text on the image in black:
         g2d.setFont(f);
         g2d.setColor(Color.black);
         g2d.drawGlyphVector(glvec, -bounds.x, -bounds.y);
         // Save the image as PNG to text.png:
         ImageIO.write(image, "png", new java.io.File("text.png"));
         // // Show a preview of the image (optional)
         // JLabel jl = new JLabel(new ImageIcon(image));
         // JFrame jf = new JFrame("Text to PNG");
         // jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         // jf.getContentPane().add(jl);
         // jf.pack();
         // jf.setVisible(true);
    }

  • Reading Excel files in Java --

    Hi,
    I am trying to read an excel file from Java. It only reads the column, but I want to print the rows, which intersect with the SQL query. The following source displays only values of a column. No problem, but I would like to see the corresponding row numbers or simply number of rows. Can anyone suggest me what to do ASAP?
    Thanks,
    Gunter
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class ExcelReadTest1{
    public static void main(String[] args){
    Connection connection = null;
    try{
    //Vector vector = new Vector();
    String myString="";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection( "jdbc dbc ata-list" );
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery( "Select caseid from [sa3$] where iSchool=2" );
    //ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    int row_num=1;
    while ((rs !=null) && rs.next()) {
    myString += "\n Row " + row_num++ + " ";
    for (int i = 1; i <= numberOfColumns; i++)
    //myString += "\n " + rsmd.getColumnName(i);
    myString += " : " + rs.getString(i);
    System.out.println(myString);
    if (i >1)
    System.out.print(", ");
    String columnValue = rs.getString(i);
    System.out.print(" " + columnValue);
    System.out.println("");
    st.close();
    con.close();
    } catch(Exception ex) {
    System.err.print("Exception: ");
    System.err.println(ex.getMessage());

    I took your code and reworked it to access a little database I keep of students at a small private school where my wife works. The Student table has columns "studentID", "firstname", "lastname", and "gradyear".
    Running your code for the output got the following. I cut and pasted the output after it had run through the first 4 students, so you can see what it's doing.
    Row 1 : 1
    1
    Row 1 : 1 : Audrey
    , Audrey
    Row 1 : 1 : Audrey : Budington
    , Budington
    Row 1 : 1 : Audrey : Budington : 2015
    , 2015
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2
    2
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia
    , Cecilia
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo
    , DeRigo
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    , 2015
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3
    3
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena
    , Serena
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes
    , Downes
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    , 2015
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4
    4
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan
    , Dylan
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan : Gellert
    , Gellert
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan : Gellert : 2015
    , 2015
    You need to figure out the flow of the thing and your println() calls and your looping. Eventually if you straighten it out you will get something like
    Row 1 : 1 : Audrey : Budington : 2015
    Row 2 : 2 : Cecilia : DeRigo : 2015
    Row 3 : 3 : Serena : Downes : 2015
    Row 4 : 4 : Dylan : Gellert : 2015
    Row 5 : 5 : Benjamin : Miller : 2015
    Row 6 : 6 : Timothy : Bolan : 2014
    Row 7 : 7 : Javin : deMello-Folsom : 2014
    Row 8 : 8 : Elizabeth : Eppolito : 2014
    Row 9 : 9 : Harrison : Evans : 2014
    Row 10 : 10 : Emily : Fay : 2014
    *** etc***
    which is what you want, isn't it?

Maybe you are looking for

  • InDesign CC slows down significantly upon placing a Microsoft Word for Mac 2011 file

    I'm running the latest Mavericks OS on a brand new iMac 27" 3.5 GHz Intel Core i7 computer with 32 GB RAM. The slowdown occurs even if ID is the only app running. The Word files consist mainly of text which are typically book maunscripts. It doesn't

  • Errors in my console log attributable to IPv6

    I was getting these errors every minute or so. 05/24/10 7:10:11 PM configd[14] network configuration changed. 05/24/10 7:11:21 PM configd[14] network configuration changed. 05/24/10 7:11:22 PM configd[14] network configuration changed. 05/24/10 7:12:

  • HP laserjet 1020 Win7 X64

    Tried both of the drivers off HP.com and I cannot get the printer to print a test page.  I tried the printer on the old PC which is a Windows 7 32bit machine and tested fine. 

  • Feedburner w/itunes feed details not updating

    Ive been having an issue for MONTHS where my feedburner manipulated feed refuses to update with the new summary of my podcast feed from what it was originally set to in itunes. The only thing I can think of is that this is because of some weird itune

  • I cloud terms and conditions

    after update to ios7 on iphone 5 new iclouud terms and conditions must accept ther is error message unable to connect to server how can i solve this ?? with kind regards