on 09-12-2007 7:02 AM
Hello,
I would be really grateful if anybody can please provide me with generic code/tutorial which would be used to download and upload excel file in NWDS 2004s.
Thanks!!
Rahul.
Hi Rahul
You can create generic DC for Excel file upload and download.
In this DC create a method for excel download.Parameters to this methos would be reference node of type IWDNode, two String arrays one for attributes to be displayed and other for header data to be displayed in the Excel.
1]Now add this DC as used DC in your DC where you will specify File download UI element.
2]Call the method that you have created by passing the node reference,attributes,header data as parameters to this method.
In the same way for file upload create a method to upload file and call this method from your parent DC.
For using file upload & download UI element in 2004s please go through the following links.
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/fdf9c528d45171e10000000a1553f7/frameset.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/webDynproJava-ExportingTableDataUsingOn-DemandStreams-SAPNW+7.0&
/people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities
Regards
Gauri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
chk it
/people/subramanian.venkateswaran2/blog/2006/10/02/enhanced-file-upload--uploading-and-processing-excel-sheets
/people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
Upload Excel file.
1)Add jxl jar folder in the lib folder of ur project.
2)Go to properties of ur project and add jar to ur project.
3)Using the File upload ui ,browse and upload the file.
4)Write the read file in to ur server location using fileoutput stream.
5)then using code u can read the excelfile from the server location itself.
Here is the code:
IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
/** get the name of excel file and storing it in the server with the same name and extention****/
binaryType=IWDModifiableBinaryTypeattInfo.getModifiableSimpleType();
fileuploaded = binaryType.getFileName();
byte b[] = wdContext.currentContextElement().getUpload();
File filename =new File("
<Server name>
<folde name>
" + fileuploaded);
try {
FileOutputStream out = new FileOutputStream(filename);
out.write(b);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/**Readind from the server**/
int iRows = 0;
try { Workbook wb = null;
Sheet sheet = null;
wb = Workbook.getWorkbook(filename);
sheet = wb.getSheet(0);
int iColumns = sheet.getColumns();
iRows = sheet.getRows();
int i = 0;
//get Cell contents by (COLUMN, ROW);
for (int r = 0; r < iRows; r++) {
for (int c = 0; c < iColumns; c++) {
Cell cell = sheet.getCell(c, r);
characterarray = cell.getContents();
//wdComponentAPI.getMessageManager().reportSuccess("Row"r characterarray);
i++;
}
}
wb.close();
Declare Globally
//@@begin others
String fileuploaded;
IWDModifiableBinaryType binaryType;
String characterarray[] = new String[1000];
//@@end
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 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.