Detailed Method Reference

Namespace: Canley.Utility.CSV
Class: CanleyCSVWriter

Export

public static string Export(List<string[]> grid)
  • Description: Converts a list of string arrays into a standard-compliant CSV string. This is a static utility method, allowing for quick serialization without needing to instantiate a CanleyCSVWriter object.

  • Workflow:

    1. Iterative Processing: Loops through each string[] within the provided list.
    2. Standard Compliance: Automatically handles special characters. If a cell contains a comma (,), a newline (\n), or a double-quote ("), the method wraps the cell in quotes and escapes internal quotes.
    3. Serialization: Joins row elements with a comma and appends the appropriate line terminator.
  • Parameters:

    • grid: A List<string[]> representing the rows and columns to be serialized.
  • Returns: string (The full, formatted CSV content).

  • Example:

// Assuming myGridData is a List<string[]>
string output = CanleyCSVWriter.Export(myGridData);

IMPORTANT

Use this static method when you already have your data structured in memory and simply need a one-off conversion to a CSV string.