on 12-05-2007 10:19 AM
Hi Experts,
I want to convert a table content to a Excel file and store it in the local harddisk.The harddisk locatication must be choosed by the user at runtime through filedalog. Please help me out in this issue as soon as possible
Regards
Noel,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.