cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Download Excel template saved in mimes

Former Member
0 Kudos

Hi all,

I had a excel template saved in Mimes and wanted to download on click of Link to action etc...

Tried many codes related to cachedwebresource but not able to resolve it

Everytime on running the application, result view comes wid contact administrator.No error on it...

Kindly help.

Thanks n best regards

Mandeep Kaur

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

use this code to open attachment from mimes


try{
		/** get file as binary */
		File file = new File(
					WDURLGenerator.getResourcePath(
						wdComponentAPI.getDeployableObjectPart(),
						"Excel_FileName"));
		FileInputStream instream = new FileInputStream(file);
		long filelen = file.length();
		
		byte[] binary = new byte[(int)filelen];
		
		int offset = 0;
		int numread = 0;
		while(offset<binary.length &&
				(numread = instream.read(binary,
				 offset,
				  binary.length-offset))>=0){
				  	
			offset +=numread;
		}
		instream.close();

		/** create Resource out of binary read */
		if(binary!=null){
			cachedresource = WDWebResource.getWebResource(binary, WDWebResourceType.XLS);
			url = cachedresource.getURL();
		}

		/** create window to open document */
		IWDWindow docwin = wdComponentAPI
							.getWindowManager()
							.createNonModalExternalWindow(url, "EcxelFileName");
		docwin.show();

	}catch(Exception e){
		msgBox("error reading file");
	}

let me know the status

nikhil

Former Member
0 Kudos

Hi Nikhil,

Thanks for ur answer. But i m stil n ot able to resove it.

I need to know where to define the cachedResource and msgBox(String) method ??? Its giving undefined error on both above locations...

Kindly reply

Thanks n Best Regards

Mandeep Kaur

Answers (0)