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>

Similar Messages

  • How to create an Excel file from XML in the Receiver File Adapter Comm Ch

    How do I create an Excel file from XML in the Receiver File Adapter Communication Channel? I have my mapping done and I am outputting the file as a comma delimited csv file. However, the target can only process an Excel file (.xls). How can I generate an Excel in XI?
    I saw this blog, but I don't know how to create a XSLT transformation.
    /people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible
    Any help would be appreciated. Thanks.

    Here are the steps I took to create an XSLT transformation in XI 3.0:
    1. I created my source and target XSDs using XMLSpy.
    2. I created the XSLT mapping from source to target in XMLSpy (referencing the souce XSD schema).
    3. I created another XSLT mapping to format the target into Excel XML.
    4. Import the source and target XSDs in the IR's External Definitions
    5. Zip each XSLT mapping (.xls) and import it into the IR's Imported Archives
    6. Reference the XSL mappings in the Interface Mapping

  • How I can create a XML file from java Aplication

    How I can create a XML file from java Aplication
    whith have a the following structure
    <users>
    <user>
    <login>anyName</login>     
    <password>xxxx</password>
    </user>
    </users>
    the password label must be encripted
    accept any suggestion

    Let us assume you have all the data from the jsp form in an java bean object..
    Now you want a xml file. This can be acheived in 2 ways
    1. Write it into a file using java.io classes. Say you have a class with name
    write("<name>"+obj.getName+</name>);
    bingo you have a flat file with the xml
    2. Use data binding to do the trick
    will recommend JiBx and Castor for the 2nd option
    Regards,
    Rajagopal

  • Creating an Excel file from table with 40,000 records

    I need help with creating an Excel file for client that has a
    table of 40,000 records. I have code that generates the Excel and
    has worked well in the past but with this much data it is timing
    out.
    I've already informed the client that Excel has limit of
    66000 records. So it might be better to export to CSV as the data
    in this table is going to keep growing.
    If you have time to work with me on this , contact me a
    alexagui [at] gmail [dot] com
    and I can send you more details so you can put together an
    accurate quote.
    Thanks,
    Alex

    asdren_one wrote:
    > I need help with creating an Excel file for client that
    has a table of 40,000
    > records. I have code that generates the Excel and has
    worked well in the past
    > but with this much data it is timing out.
    >
    > I've already informed the client that Excel has limit of
    66000 records. So it
    > might be better to export to CSV as the data in this
    table is going to keep
    > growing.
    >
    > If you have time to work with me on this , contact me a
    alexagui [at] gmail
    > [dot] com
    > and I can send you more details so you can put together
    an accurate quote.
    For so many records my guess is that the concatenation times
    the most
    time so you'll need to use StringBuffer to build the string.
    Google for
    coldfusion and stringBuffer:
    http://www.stillnetstudios.com/2007/03/07/java-strings-in-coldfusion/
    Mack

  • How to create an excel file from SAP?

    I needed to create an excel file(with out data) format with fields read from a table.

    check FM
    EXCEL_OLE_STANDARD_DAT
    Regards
    prabhu

  • 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

  • Automatically create new Excel file from template using data from a selected row in a separate Excel file

    I am fairly new to Macro and VBA in Excel. I am trying to reduce the amount of work involved in a task that is performed often in our office. Currently, the task involves using 2 separate Excel files. One file is a tracking sheet and the second is the document
    that gets sent out to the client. The second document has all the same information that is inserted into the tracking sheet. What I would like to do is have the information that is in one row on the tracking sheet populate into a new excel file that is created
    automatically from an existing template.
    I have been able to make this partially work. What I have been able to achieve is have the cell that is selected in the tracking sheet (the description field) copy into the new file that is created from the template that is on our server.
    Sub NewRFI()
    ' NewRFI Macro
        MsgBox Selection.Address(ReferenceStyle:=xlA1, _
                               RowAbsolute:=False, ColumnAbsolute:=False)
        Selection.Copy
        Workbooks.Add Template:= _
            "template file path goes here"
        Range("C14").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
        Range("C14").Select
        Application.CutCopyMode = False
    End Sub
    What I need to do is get the rest of the information from that same row in the tracking sheet to copy to the new file as well. The other information includes the document number (one cell to the left of the selected cell), who it is from (one cell to the
    right of the selected cell), and the date (two cells to the right of the selected cell). As stated, this information is all in the same row on the tracking sheet. Each piece of information needs to be copied to a certain cell in the new file and I do not want
    the source formatting to be copied to the new file.
    Ideally, I would like it to operate like so: select the first cell in the row (in this case would be the document number field). Then click a button to run the macro that will then copy the information from that row in the tracking sheet to specific cells
    in the new file that is created from the template.
    This process will save us from having to either manually copy and paste the information into the new file or re-type the same information that is already in the tracking sheet.
    This is probably a simple thing to do but it would be great if anybody had some insight on this issue. Thanks in advance!

    Try code like the following. You will have to change the target cells (D25, F1 and H4) to the ones you want, I just used some arbitrary cells as example.
    Sub NewRFI()
    Dim rngCell As Range
    Set rngCell = ActiveCell
    MsgBox Selection.Address(ReferenceStyle:=xlA1, _
    RowAbsolute:=False, ColumnAbsolute:=False)
    Workbooks.Add Template:="template file path goes here"
    Range("C14").Value = rngCell.Value
    ' Change the target cells as needed
    Range("D25").Value = rngCell.Offset(0, -1).Value
    Range("F1").Value = rngCell.Offset(0, 1).Value
    Range("H4").Value = rngCell.Offset(0, 2).Value
    End Sub
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Creating an xml file from java.

    I trying to create an xml file using a java program. I just wondering what is the best way to go about it and what should i use jdom ,xerces sax etc.

    Use JAXP+SAX.
    Here an example:import java.io.*;
    // SAX classes.
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    //JAXP 1.1
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import javax.xml.transform.sax.*;
    // PrintWriter from a Servlet
    PrintWriter out = response.getWriter();
    StreamResult streamResult = new StreamResult(out);
    SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
    // SAX2.0 ContentHandler.
    TransformerHandler hd = tf.newTransformerHandler();
    Transformer serializer = hd.getTransformer();
    serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
    serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");
    serializer.setOutputProperty(OutputKeys.INDENT,"yes");
    hd.setResult(streamResult);
    hd.startDocument();
    AttributesImpl atts = new AttributesImpl();
    // USERS tag.
    hd.startElement("","","USERS",atts);
    // USER tags.
    String[] id = {"PWD122","MX787","A4Q45"};
    String[] type = {"customer","manager","employee"};
    String[] desc = {"Tim@Home","Jack&Moud","John D'o�"};
    for (int i=0;i<id.length;i++)
      atts.clear();
      atts.addAttribute("","","ID","CDATA",id);
    atts.addAttribute("","","TYPE","CDATA",type[i]);
    hd.startElement("","","USER",atts);
    hd.characters(desc[i].toCharArray(),0,desc[i].length());
    hd.endElement("","","USER");
    hd.endElement("","","USERS");
    hd.endDocument();
    [i]This xml generation program might be the best solution because it uses JAXP 1.1 so it will work under JDK 1.4 or JDK 1.2/1.3 with XALAN2 library (or any XML library JAXP 1.1 compliant). It's also memory-friendly because it doesn't need DOM.
    See http://www.javazoom.net/services/newsletter/xmlgeneration.html
    Hope That Helps                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Create an XML file from Java

    I'm a new user of XML. I've a very important question:
    Is it possible create an XML file using some java package? If yes what package i must use? JDOM is the right product?
    Thanks

    Yes, JDOM is the right choice for 99% of your work.
    DOM is too difficult to use.
    That is the reason why JDOM has been developped.

  • Create a new File from java code

    Hi,
    I'd like to create a new File on IFS, using Java code. Moreover, this file will be an image file, and I'd like to store meta data with this file... and then execute a search on this meta data.
    I know it must not be very difficult to do, but I can't find any code sample.
    Does anyone could give me some usefull link or advice ?
    thanks in advance,
    Roger.

    First of all, you need to create your custom class. You can do it using iFS Manager, extending the class DOCUMENT. Let's call this class IMAGE with the attributes "length", "width", "colorDepth". Take a look at the code that creates one instance:
    You need one instance of LibrarySession (that appears in the code named "ifsSession").
    You need also the InputStream of the image you want to store (that appears in the code named "contentStream").
    // Setting the attributes
    DocumentDefinition def = new DocumentDefinition(ifsSession);
    def.setClassname("IMAGE");
    def.setAttribute("NAME", AttributeValue.newAttributeValue("nameOfTheImage"));
    def.setAttribute("LENGTH", AttributeValue.newAttributeValue(100));
    def.setAttribute("WIDTH", AttributeValue.newAttributeValue(230));
    def.setAttribute("COLORDEPTH", AttributeValue.newAttributeValue(1024));
    def.setContentStream(contentStream);
    // Creation
    Document doc = (Document) ifsSession.createPublicObject(def);
    I hope this helps,
    Fabio Nunes

  • How to Create a excel file from a table.

    i want to excel output from a oracle table.

    Please use below one:
    DECLARE
    CURSOR C1
    IS
    SELECT DISTINCT JVH_LCM_LCTN_CODE FROM F_JV_HDR;
    CURSOR C2 (V_LOC VARCHAR2)
    IS
    SELECT *
    FROM
    (SELECT *
    FROM F_JV_HDR
    WHERE JVH_JV_DATE <= '31-OCT-2011'
    AND JVH_DSM_DCMNT_TYPE = 'SJV'
    AND JVH_LCM_LCTN_CODE = V_LOC
    ORDER BY JVH_JV_DATE DESC
    WHERE ROWNUM <= 10
    UNION ALL
    SELECT *
    FROM
    (SELECT *
    FROM F_JV_HDR
    WHERE JVH_JV_DATE > '31-OCT-2011'
    AND JVH_DSM_DCMNT_TYPE = 'SJV'
    AND JVH_LCM_LCTN_CODE = V_LOC
    ORDER BY JVH_JV_DATE
    WHERE ROWNUM <= 10;
    v_file utl_file.file_type;
    linebuf VARCHAR2(32767);
    BEGIN
    v_file := utl_file.FOPEN('MAIL_OUTPUT','F_JV_HDR-SJV.csv','w') ;      --Change the CSV file name
    LINEBUF := 'JVH_LCM_LCTN_CODE,JVH_DSM_DCMNT_TYPE,JVH_JV_TMPRY_NMBR,JVH_JV_TMPRY_DATE,JVH_SRCE_INDCTR,JVH_CRTD_DATE,JVH_CRTD_BY,JVH_ATHRSTN_STS,JVH_DSM_TRM_TR_CODE,JVH_DSM_DCMNT_SRS,JVH_LCM_LCTN_CODE_BOOK,JVH_ATHRSTN_RQRD_INDCTR,JVH_FNCL_CLSRE_INDCTR,JVH_TRNSCTN_WITH_INDCTR,JVH_TRNSCTNR_CODE,JVH_JV_NMBR,JVH_JV_DATE,JVH_RMRKS,JVH_JV_RVRSD_NMBR,JVH_CHQE_DUE_DATE,JVH_ATHRSD_DATE,JVH_ATHRSD_BY,JVH_TR_CODE_RVRSD,JVH_DCMNT_TYPE_RVRSD,JVH_JV_RVRSD_INDCTR,JVH_NJV_TAG,JVH_TYPE,JVH_AUTO_RVSL_INDCTR,JVH_AUTO_RVSL_DATE,JVH_BUS_BKS_UPLOAD';                --Chage the headings
    utl_file.put_line(v_file,linebuf);
    FOR I1 IN C1
    LOOP
    FOR I2 IN C2(I1.JVH_LCM_LCTN_CODE)                    --Change the cursor parameter
    LOOP
    LINEBUF := I2.JVH_LCM_LCTN_CODE||','||I2.JVH_DSM_DCMNT_TYPE||','||I2.JVH_JV_TMPRY_NMBR||','||I2.JVH_JV_TMPRY_DATE||','||I2.JVH_SRCE_INDCTR||','||I2.JVH_CRTD_DATE||','||I2.JVH_CRTD_BY||','||I2.JVH_ATHRSTN_STS||','||I2.JVH_DSM_TRM_TR_CODE||','||I2.JVH_DSM_DCMNT_SRS||','||I2.JVH_LCM_LCTN_CODE_BOOK||','||I2.JVH_ATHRSTN_RQRD_INDCTR||','||I2.JVH_FNCL_CLSRE_INDCTR||','||I2.JVH_TRNSCTN_WITH_INDCTR||','||I2.JVH_TRNSCTNR_CODE||','||I2.JVH_JV_NMBR||','||I2.JVH_JV_DATE||','||I2.JVH_RMRKS||','||I2.JVH_JV_RVRSD_NMBR||','||I2.JVH_CHQE_DUE_DATE||','||I2.JVH_ATHRSD_DATE||','||I2.JVH_ATHRSD_BY||','||I2.JVH_TR_CODE_RVRSD||','||I2.JVH_DCMNT_TYPE_RVRSD||','||I2.JVH_JV_RVRSD_INDCTR||','||I2.JVH_NJV_TAG||','||I2.JVH_TYPE||','||I2.JVH_AUTO_RVSL_INDCTR||','||I2.JVH_AUTO_RVSL_DATE||','||I2.JVH_BUS_BKS_UPLOAD; --Change the cursor values
    utl_file.put_line(v_file,linebuf);
    END LOOP;
    END LOOP;
    UTL_FILE.FCLOSE(V_FILE);
    END;
    /

  • How to create a executable file from .java file?

    Well usually we would compile and run our program using jdk1.x. Can we create a .exe file so that it will run everytime I open it without compile and run it?
    Regards,
    Ng

    hai,
    you can create a batch file,in it define the commands javac and java.so that whenever u are running the batchfile it is compiled and the program is executed..
    it will work..
    bye,
    j.mouli

  • 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.

  • Create dynamically xml file from java.

    Hi all,
    I got class information in java program. I have to put method name and return type into xml. The xml file is like this and i have created this file.
    <method>
    <name></name>
    <returnType></returnType>
    </method>
    Now when I get method information I want to put it in xml, not by writing each method name explicitly in file, mean i have to load this xml into memory for that what should i do?
    Please help me I am new in XML.
    Thanks in advance.
    -regards
    bunty

    If you save your XML file as "methodinfo.xml", you can use the following code:import java.io.File;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder parser = factory.newDocumentBuilder();
      Document doc = parser.parse(new File("methodinfo.xml"));
      Node nameNode = doc.getElementsByTagName("name").item(0);
      Node returnTypeNode = doc.getElementsByTagName("returnType").item(0);
      nameNode.setTextContent("the name of the method");
      returnTypeNode.setTextContent("the return type of the method");
      DOMSource source = new DOMSource(doc);
      StreamResult result = new StreamResult(System.out);
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      System.out.println("This is the content of the XML document:\n");
      transformer.transform(source, result);
    catch (Exception e){
    ...The content of the XML document will be displayed as follows:<?xml version="1.0" encoding="UTF-8" ?>
    <method>
      <name>the name of the method</name>
      <returnType>the return type of the method</returnType>
    </method>

  • How2 create xml & ent  files from JAVA? (xml that gets data from ent file)

    Is there any API that can make it easy?
    * For parsing XML I use JDOM parser
    I want to create file like this:
    XML file: some.xml
    <?xml version="1.0"?>
    <!DOCTYPE xfat [
    <!ENTITY  d_request SYSTEM  "some.ent">
    ]>
    <!--
    /home/bNUMBER/Programs/XFAT/runxfat some.xml
    -->
    <xfat title = 'Fat Title (some) '>
    <database  filename = 'Some_Data/some.xml'/>
    <snc  filename  = "../snc/snc.xml"/>
    <configuration sp = '../sp/some_only.xml' name='Some_A-H'>
       &d_request;
    </configuration>
    </xfat>and ent file:
    <ddef title    = 'some d def title (some)'>
         <dcalc  snc    = '7_A9'
                meas   = 'm73'
                red    = 'GOOD' binval='MCMS' lug='YES'/>
    </ddef>

    has anyone idea what to search?

Maybe you are looking for

  • Runtime exceptions in custom taglib

    I am getting errors of the type:           javax.servlet.ServletException: runtime failure in custom tag           The problem is the error is happening in a taglib, but Weblogic is hiding the           original stack trace, and substituting it's own

  • Problem importing photos with OS 10.4.6

    I have two PowerMacs G5, one first gen G5 1.8 GHz and a Dual 1.8 GHz. I can easily download from iPhotos or directly on my HP 735 Photosmart pictures that I take when using my Dual G5. But on the other computer the photos get corrupted and are theref

  • I am wanting to personalise my iPod and wonder how I do this

    hi hi am wanting to person,it's my iPod and wonder how I do this, I have tried via ITunes, but unable to see how I do this. regards yvonne

  • Does sync for a G4 still work?

    Does sync for a G4 still work, cannot obtain iCloud on a G4.

  • Change XML after CALL FUNCTION 'SDIXML_DOM_TO_XML'

    Hi All, i need a possibility to change a proper formed XML into something like this. Example: <PRESOL>   <DATE> 0521 <YEAR> 99 <CBAC> demo <PASSWORD> DEMO <ZIP> 22030 <CLASSCOD> B <NAICS> 123456 </PRESOL> Thanks, Christoph