[]
Represents the context for parsing the current CSV cell.
The context provides the zero-based row and column indexes of the CSV cell being parsed, together with the original cell text before the custom parser changes the parsed result.
public class CsvParseContext
Public Class CsvParseContext
CsvOpenOptions options = new CsvOpenOptions();
options.Parser = new LeadingZeroParser();
string filePath = Path.Combine(Path.GetTempPath(), "data.csv");
File.WriteAllText(filePath, "Code\n0012");
workbook.Open(filePath, options);
IWorksheet activeSheet = workbook.ActiveSheet;
class LeadingZeroParser : ICsvParser
{
public void Parse(CsvParseResult result, CsvParseContext context)
{
if (context.Column == 0 && context.Text.StartsWith("00"))
{
result.Value = context.Text;
}
}
}
| Name | Description |
|---|---|
| Column | Gets the column index of the current cell. |
| Row | Gets the row index of the current cell. |
| Text | Gets the original text of the current cell before parsing. |