on 02-12-2008 1:17 PM
Hi,
Kindly let me know how to export data from table to csv file which i wanna save on my desktop.
i hav gone throgh so many blogs, which r given how to export to excel file.
i want to export to csv.
thanks in advance
Hi,
1.Create a text file.
2. Iterate through the elements of the node bind to the table.
3 Write each element concatinate attribute with "," as mentioned by you.
4. Write the element to the file
5. Close the file
Sample Code
StringBuffer strBuf = new Stringbuffer();
for(int x=0; x< wdContext.nodeTest().size(); x++) // Replace nodeTest with yours
{
ITestElement nodeElement = wdContext.nodeTest().getElementAt(x);
strBuf.append(nodeElement.getAttribute("TestAttribute1"); //Replace with yours
strBuf.append(",");
strBuf.append(nodeElement.getAttribute("TestAttribute2"); //Replace with yours
strBuf.append("\n");
}
try
{
FileWriter fileWriter = new FileWriter("data.txt");
fileWriter.write(strBuf.toString());
fileWriter.close();
}catch(Exception e)
{
e.printStackTrace();
}
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.