on 12-03-2008 10:30 AM
Hi All,
I am working on one Web Dynpro application where I can ExportTable data into Excel format.
For that I am using Web Dynpro Binary Cache.
But in runtime it is showing the Java.lang.nullpointer exception.
My doubt is do we need to add the excel.gif file in SRC folder or dynamically it will create the excel file.
Thanks,
Archana.
Hi,
Refer to this link and follow the steps mentioned in it. U will get the solution.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Archana,
you don't need to attache .gif file file in SRC folder.
you have to create .xlf file dynamically and write the data into excel file.
here is running code to create xl file
PS: before creating xl file you need to add xlf.jar file into java build path as well as lib folder of ur application
wdThis.wdGetABCController().executeBapi_Flight_Getlist_Input();
String fileName = "output" + ".xls";
IWDCachedWebResource cachedExcelResource = null;
try
{
java.io.File f = new java.io.File("output.xls");
WritableWorkbook workbook = Workbook.createWorkbook(f);
WritableFont red = new WritableFont(WritableFont.ARIAL,
WritableFont.DEFAULT_POINT_SIZE,
WritableFont.BOLD,
false,
UnderlineStyle.SINGLE,
Colour.DARK_BLUE);
WritableCellFormat redFormat = new WritableCellFormat(red);
WritableFont blue = new WritableFont(WritableFont.ARIAL,
WritableFont.DEFAULT_POINT_SIZE,
WritableFont.NO_BOLD,
false,
UnderlineStyle.NO_UNDERLINE,
Colour.BLACK);
WritableCellFormat blueFormat = new WritableCellFormat(blue);
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
// String ab=wdContext.nodeFlight_List().getNodeInfo().getAttribute("Airline").getName();
jxl.write.Label label = new jxl.write.Label(0, 0, "Id", redFormat);
sheet.addCell(label);
label = new jxl.write.Label(1,0,"No",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(2,0,"Arrival city",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(3,0,"Depart",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(4,0,"Depart. city",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(5,0,"Curr.",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(6, 0,"Airline",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(7,0,"Airport",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(8,0,"ISO",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(9,0,"Apt",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(10,0,"Airfare",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(11,0,"Arrival Date",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(12,0,"Arrival",redFormat);
sheet.addCell(label);
label = new jxl.write.Label(13,0,"Date",redFormat);
sheet.addCell(label);
for(int j=1;j<wdContext.nodeFlight_List().size();j++)
{
for(int i=0;i<13;)
{
//if(wdContext.nodeFlight_List().isSelected(j)){
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getAirlineid(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getConnectid(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getCityto(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getDeptime().toString(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getCityfrom(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getCurr(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getAirline(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getAirportfr(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getAirportto().toString(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getCurr_Iso().toString(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getPrice().toString(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getArrdate().toString(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getArrtime().toString(),blueFormat);
sheet.addCell(label);
label = new Label(i++,j,wdContext.nodeFlight_List().getFlight_ListElementAt(i).getFlightdate().toString(),blueFormat);
sheet.addCell(label);
}
}
// }
workbook.setColourRGB(Colour.LIME, 0xff, 0, 0);
workbook.write();
FileInputStream excelCSVFile = new FileInputStream(f);
cachedExcelResource =
getCachedWebResource(
excelCSVFile,
fileName,
WDWebResourceType.getWebResourceType(
"xls",
"application/ms-excel"));
wdContext.currentContextElement().setExcelURL(cachedExcelResource.getURL());
workbook.close();
}
catch (Exception ex)
{
ex.printStackTrace();
}
//@@end
}
Thnaks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For exporting data to excel you dont need to have any file in your SRC folder. You can also achieve the same functinality using IWDWebResource. For this you need to add jxl.jar file. Step by step procedure is mentioned in below link. Finally you need to have a linktoURL UI element.
[https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4210] [original link is broken] [original link is broken] [original link is broken];
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Archana,
Do u mean Export to Excel Functionality?
If so, there is no need to add any files in the SRC folder.
Can you post the code which you used? or the Complete stack of the error?
Regards,
Padmalatha.K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.