Hi,
For this, Use FileDownload UI Element. and bind the URL of the file to the
Resource property of it.
For Writing to excel file From Data in Table
File f=new File("table.xls");
FileOutputStrean fos=new FileOutputStream(f);
for(int i=0;i<wdContext.node<TableNode>().size();i++)
{
byte []b=wdContext.node<TableNode>().get<TableNode>ElementAt(i).get<Field1>().getBytes();
fos.write(b);
fos.write("\t".getBytes());
[]b=wdContext.node<TableNode>().get<TableNode>ElementAt(i).get<Field2>().getBytes();
fos.write(b);
fos.write("\t".getBytes());
fos.write("\n".getBytes());
}
}
For generating URL Use
FileInputStream fis = new FileInputStream(f);
FileChannel fc = fis.getChannel();
byte[] data = new byte[(int)(fc.size())];
ByteBuffer bb = ByteBuffer.wrap(data);
fc.read(bb);
IWDCachedWebResource objCachedWebResource = null;
if (data != null)
{
objCachedWebResource = WDWebResource.getWebResource(data,WDWebResourceType.XLS);
objCachedWebResource.setResourceName(f.getName());
}
wdContext.currentContextElement().setResource(objCachedWebResource.getAbsoluteURL());
wdContext.currentContextElement().setBehaviour(WDFileDownloadBehaviour.ALLOW_SAVE);// this property will be in 2004s only
Regards
LakshmiNarayana
Add a comment