Skip to Content
author's profile photo Former Member
Former Member

Download a table in excel file

Hi to everybody,

I have a a webdynpro view with a table and I wanto to download some of its columns to an excel file. How can I do it? I read some topics about this problem on this forum but I didn't understand completely the answers because I am not so skilled with java programming. Can you help me??

Thank you very much,

Antonio

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2004 at 12:13 PM

    Hi Antonio,

    assuming your table is bound to a value node A with 3 columns (e.g. value attributes) CA/CB and CC you want to export the contents of this columns for a usage in Excel, it's sufficient to loop through the context nodes and create a text file where each line represents the contents of one node element and the contents of each column are separated by tabulators.

    Something like this should work (exception handling and possible performance enhancements are ommitted):

    PrintStream out = new PrintStream(new FileOutputStream("C:/temp/exceldump.xls"));
    StringBuffer sb = new StringBuffer();
    /* Output header line */
    out.println("CAtCBtCC");
    /* Output data lines */
    for (int ix = 0; ix < wdContext.node<yourNode>().size(); ix++) {
      INode<yourNode>Element el = wdContext.node<yourNode>().get<yourNode>ElementAt(ix);
      sb.setLength(0);
      sb.append(el.getCA()).append('t');
        .append(el.getCB()).append('t');
        .append(el.getCC());
      out.println(sb.toString());
    }
    out.flush();
    out.close();

    Please recognize, that this is a sample only (i've written from scratch), you should for example not open a file with a hardcoded name like done here.

    Hope that helps.

    Regards

    Stefan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 18, 2005 at 01:05 PM

    Hi Antonio,

    Check the following blog "Create an excel file from JAVA using HSSF api"

    /people/prakash.singh4/blog/2005/03/16/create-an-excel-file-from-java-using-hssf-api

    In this blog Prakash Singh described how to create a excel file from JAVA.

    Write a method to parse through the table node and read values of the necesary value attributes and populate the excel using the HSSF api.

    Hope this help to solve your problem.

    Regards,

    Santhosh.C

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.