cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a File in local system

Former Member
0 Kudos

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,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (0)