CSV Engine Documentation Contents
AldenSystems.CSVEngine
CSV Engine Class Library

Writer Class

Some aspects of the Writer class are available in the commercial version only.

Writer writes data to a file in CSV format.

For a list of all members of this type, see Writer Members.

System.Object
AldenSystems.CSVEngine.Writer

[Visual Basic]
NotInheritable Public Class Writer
[C#]
public sealed class Writer

Remarks

Writer can filter out duplicate rows through use of the filterUnique constructor parameter. Note that use of this option may cause significant additional overhead when processing very large files.

Some aspects of the Writer class are available in the commercial version only.

Example

This example demonstrates how data table contents can be copied into a csv file.

C# example:
Writer csvWriter = new Writer(@"c:\temp\test.csv");

DataTable dataTable = GetTable(); //some method that returns a data table

foreach(DataRow dataRow in dataTable.Rows)
{
    Row saveRow = new Row();
    
    for(int columnIndex = 0; columnIndex < dataTable.Columns.Count; columnIndex++)
    {
        saveRow.AddValue(dataRow[columnIndex].ToString());
    }
    
    csvWriter.Write(saveRow);
}

csvWriter.Close();
VB example:
Dim csvWriter = New Writer("c:\temp\test.csv")
Dim dataTable As DataTable
Dim dataRow As DataRow

dataTable = GetTable() 'some method that returns a data table

For Each dataRow In dataTable.Rows
    Dim saveRow = New Row

    For columnIndex As Integer = 0 To dataTable.Columns.Count - 1
        saveRow.AddValue(dataRow(columnIndex).ToString())
    Next
    
    csvWriter.Write(saveRow)
Next

csvWriter.Close()

Requirements

Namespace: AldenSystems.CSVEngine

Assembly: CSVEngine (in CSVEngine.dll)

See Also

Writer Members | AldenSystems.CSVEngine Namespace