cancel
Showing results for 
Search instead for 
Did you mean: 

Export to CSV

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

i tried the code as u mentioned below. even tohguh its not working.....

provide me some otherway

Answers (0)