how to export table data into excel

Hi .
I want to export table data into excel file .
can anyone plz help .
with vtk (c++)

Exporting directly into Excel will require an external (non-vtk) library. You could export to a CSV (comma separated values) file instead.

vtk has the DelimitedTextWriter class which will do what I described below. Just took me a while to find it.

Forget all this and use the example above:

If your data is represented as a vtkTable, then all of the methods you need are part of this class:

vtkTable::GetValue() or vtkTable::GetRow()

If you want to add a header row to your output, use vtkTable::GetColumnName()

Basically, your code will open the file (in text format) for output, then loop over the columns, writing each column name separated by a comma and adding “\n” at the end of the header row. Then loop over each row, and within each row loop over each column and retrieve the vtkVariant value at the row, column index. You can use vtkVariant::ToString() to write it out directly as a string with default formatting, or determine the type using vtkVariant::GetType() and do custom formatting. Between each value, put a comma and at the end of each row put a “\n”. At the end of all the rows, close the file.

If your data is not a vtkTable, then you’ll have to determine how to extract the data and represent it in table form for a spreadsheet.

Thank you for your reply .

Yes,I have already exported the table data to csv file using DelimitedTextWriter.

Isn’t there any otherway to export data to excel file directly or making csv to excel .
Thank you.