cancel
Showing results for 
Search instead for 
Did you mean: 

How to DownLoad any type of File from the server(PDF,XLS,Word)

Former Member
0 Kudos

Hi experts

I am facing a problem while Downloading File from the server.

I am trying to DownLoad a Excel FIle.

When i am clicking on the FileDownLoad Link,It is showing option for save,open

and after saving ,when i am trying to open the file,It is showing in a dilog box"Un able to read file".

Can u please tell me what can be the problem and how to solve this?

Thanks

Salini

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

use this for file download.

For file down load u have to use a UI element as "File download".

u just create context attribute as setdownload_res and file data.

setdownload_res as of type "com.sap.ide.webdynpro.uielementdefinitions.Resource" then bound it to the ui element "resource".

file data as of type "com.sap.tc.webdynpro.progmodel.api.IWDInputStream"

and set calcuclated as true and read only as true.

then in doinit method u just write this code

IWDAttributePointer attr = wdContext.currentContextElement().getAttributePointer("fileData");

IWDResource res = WDResourceFactory.createResource(attr,null,WDWebResourceType.UNKNOWN);

wdContext.currentContextElement().setDownload_res(res);

wdComponentAPI.getMessageManager().reportSuccess(""+c);

after this in the getter method u write this code

IWDInputStream stream = null;

try

{

stream = WDResourceFactory.createInputStream(new FileInputStream(new File("<pathof the file to be download>")));

}

catch(Exception e)

{

e.printStackTrace();

}

return stream;

Former Member
0 Kudos

Hi Satish

Thanks for your response.

Hope it is helping me.

Can u please clarify one thing,inside the getter method while creating an instance of IWDInputStream the path to the File to be downloaded means ,the path of the File in the Application Server or Presentation Server?

If it is Application Server ,then How can i get the path where it is storing the File?