cancel
Showing results for 
Search instead for 
Did you mean: 

problem in exporting data to excel in nwds 7.3

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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.

Former Member
0 Kudos
vijay_kumar49
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

http://help.sap.com/javadocs/NW73/SPS03/CE/wdr/com.sap.wdr/com/sap/tc/webdynpro/services/sal/url/api...

Regards,

Ganesh N

Former Member
0 Kudos

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.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94...

Thank you

Regards,

Jaspreet Kaur