cancel
Showing results for 
Search instead for 
Did you mean: 

Download a table in excel file

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Stefan,

I try to run Coding, but I get a fault at

INODE<yourNode>Element el = ...

What do you mean with <yourNode> ? Columnname ?

I'm a Java - Newbie.

Could you please help me ?

Do I need the Excel-Control ?

thx a lot.

greetings

sascha

Message was edited by: Sascha Buhmann

Former Member
0 Kudos

greetings

sascha

Message was edited by: Sascha Buhmann