on 11-10-2011 1:08 PM
Hi All,
I was using the following code for exporting data to excel in NWDS 7.3
private IWDCachedWebResource getCachedWebResource(byte[] file, String name,
WDWebResourceType type) {
IWDCachedWebResource cachedWebResource = null;
if (file != null) {
cachedWebResource = WDWebResource.getWebResource(file, type);
cachedWebResource.setResourceName(name);
}
return cachedWebResource;
}
I was getting the error in the following line cachedWebResource = WDWebResource.getWebResource(file, type); when I clicked the quick help it ststed the getWebResource method is depricated. Kindly provide some assistance on what is the new method in its place.
Thank you
Regards,
Preet Kaur
Hi all,
I have this problem in 7.3:
The initial exception that caused the request to fail, was:
java.lang.NullPointerException: while trying to invoke the method com.sap.tc.webdynpro.services.sal.core.IServerPlatformImplementation.getWebResourceFactory() of an object returned from com.sap.tc.webdynpro.services.sal.core.AbstractManager.getServerPlatformImplementation()
at com.sap.tc.webdynpro.services.sal.url.api.WDWebResource.getWebResource(WDWebResource.java:71)
Can you help me someone?
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Preet,
You can refer the following links:
http://wiki.sdn.sap.com/wiki/display/WDJava/ExporttoExcel(WithoutthirdpartyAPIs)
Regards,
Jithin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can follow this
IWDResource cachedExcelResource = WDResourceFactory.createCachedResource(excelCSVFile, "FileName.xls", WDWebResourceType.XLS, false);
[Document|http://help.sap.com/saphelp_nw04s/helpdata/en/4a/fb8342a7d30d53e10000000a155106/content.htm]
Hope this is help full for u
Regards
Vijay
Edited by: VijaySAPEP on Nov 10, 2011 8:23 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Preet,
You can use
WDResourceFactory.createCachedResource(InputStream, String, WDWebResourceType, boolean)
instead of the deprecated method.
You can also refer to the javadoc for the same.
Regards,
Ganesh N
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ganesh,
Thanks that worked fine, but when we go further we are facing problem ie
byte[] excelXMLFile;
IWDCachedWebResource cachedExcelResource = null;
String fileName = dataNode.getNodeInfo().getName() + ".xls";
try {
// create Excel 2003 XML data as a byte array for the given context node,
// attributes and headers
excelXMLFile = toExcel(dataNode, columnInfos).getBytes("UTF-8");
// create a cached Web Dynpro XLS resource for the given byte array
// and filename
cachedExcelResource = getCachedWebResource(
excelXMLFile, fileName, WDWebResourceType.XLS);
// Store URL and file name of cached Excel resource in context.
if (cachedExcelResource != null) {
wdContext.currentContextElement().setExcelFileURL(
cachedExcelResource.getURL());
wdContext.currentContextElement().setExcelFileName(
cachedExcelResource.getResourceName());
// Open popup window with a link to the cached Excel file Web resource.
openExcelLinkPopup();
} else {
wdComponentAPI.getMessageManager().reportException(
"Failed to create Excel file from table!", true);
}
} catch (UnsupportedEncodingException e) {
wdComponentAPI.getMessageManager().reportException(
e.getLocalizedMessage(), true);
} catch (WDURLException e) {
wdComponentAPI.getMessageManager().reportException(
e.getLocalizedMessage(), true);
}
The above bold lines also would need to be converted to inputstream, but not sure how to correct that
We are following the below pdf for the implementation.
Thank you
Regards,
Jaspreet Kaur
User | Count |
---|---|
93 | |
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.