Skip to Content
author's profile photo Former Member
Former Member

Creating a File in local system

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,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 10:45 AM

    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
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.