on 12-14-2005 6:00 PM
Hi
I have to develop a functionality that consent to create a sale order by uploading data (material code and quantity) from an excel file.
How can i upload the content of an excel file into a table using java web dynpro technoloy?.
Thank you for your attention
Best Regards
Alessandro Fernandez
Hallo Alessandro,
there is no IWDExcel2Context-API exsiting in Web Dynpro. To copy the excel content to the context you have to utilize some external service API for reading excel files (/people/prakash.singh4/blog/2005/03/16/create-an-excel-file-from-java-using-hssf-api). Populating context nodes should then be no problem.
Regards, Bertram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To Valery Sylaev
Thanks for your answer but I need more information about the uploading from an excel file.
I try to explain in detail the issue.
Well I have an I-View with a table (layout data: RowHeadData). In this table the user can write the material code and the quantity and proceed with the saving of the sale order.
An another way to create the sale order is to import the material code and the quantity from an excel file. Trough clicking the browse button I search the excel file and by clicking the import button I need that the data, contained in the excel, are written in the table. The problem isnt the browsing but importing data into table.
How can I do this using java web dynpro tehcnology?
To Raman
I need to import a file .xls not a .csv.
Thank you for your attention
Best Regards
Alessandro Fernandez
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alessandro,
I have created the File for preparing the question bank and stored it in the data base from an excel sheet which is in CSV format.
Write the code in the init method
IWDAttributeInfo attInfo = wdContext.getNodeInfo().getAttribute("upload");
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
This code in the Action event handler of file upload.
try{
byte b[]= wdContext.currentContextElement().getUpload();
int i=0;
String datas=new String(b);
String rowarray[]=new String[1000];
StringTokenizer datastoken=new StringTokenizer(datas,"\r");
while(datastoken.hasMoreTokens())
{
rowarray<i>=datastoken.nextToken();
i++;
}
String characterarray[]=new String[1000];
or(int k=0, m=0;m<i;m++)
{
StringTokenizer stn1=new StringTokenizer(rowarray[m],",");
while(stn1.hasMoreTokens())
{
characterarray[k]=stn1.nextToken();
k++;
}
}
InitialContext ctx=new InitialContext();
javax.sql.DataSource ds=(javax.sql.DataSource)ctx.lookup("jdbc/SAPJ2EDB");
java.sql.Connection con=ds.getConnection();
java.sql.Statement stmt=con.createStatement();
int x=-1,z;
for(z=0;z<i-1;z++) {
con.setAutoCommit(false);
ResultSet rs=stmt.executeQuery("select count(*) from TMP_QUESTIONBANK1");
rs.next();
int index=rs.getInt(1)+1;
String subid=wdContext.currentNode_subElement().getTech_admin_subid();
int retIns = stmt.executeUpdate("insert into TMP_QUESTIONBANK1(INDEX,SUBJECTID,QUESTIONS,OPTIONA,OPTIONB,OPTIONC,OPTIOND,ANSWER) values("index",'"subid"','"characterarray[x].trim()"','"characterarray[x]"','"characterarray[x]"','"characterarray[x]"','"characterarray[x]"','"characterarray[x]"')");
con.commit();
con.setAutoCommit(true);
wdComponentAPI.getMessageManager().reportSuccess("hai-updated----
"+index);
}
con.close();
}
catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException("Exception "+e,true);
}
Regards,
Vijayakhanna Raman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alessandro
1. Use IWDFileUpload control to submit file
2. Use Jakarta POI / HSSF to parse content into context node elements
/people/prakash.singh4/blog/2005/03/16/create-an-excel-file-from-java-using-hssf-api
(here is "writing" covered, parsing is even simplier, refer to POI docs as well)
3. Use IWDTable to show content
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.