Skip to Content
avatar image
Former Member

problem in exporting data to excel in nwds 7.3

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Nov 10, 2011 at 01:33 PM

    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/WDWebResource.html

    Regards,

    Ganesh N

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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-acd5b6a94353?QuickLink=index&overridelayout=true

      Thank you

      Regards,

      Jaspreet Kaur

  • Nov 10, 2011 at 02:48 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 11, 2011 at 05:36 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 24, 2013 at 11:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded