[]
Represents a custom CSV parser.
Assign an implementation to the Parser property of CsvOpenOptions to inspect
each parsed CSV cell and optionally modify the parsed value or number format.
public interface ICsvParser
Public Interface ICsvParser
CsvOpenOptions options = new CsvOpenOptions();
ICsvParser parser = new LeadingZeroParser();
options.Parser = parser;
string filePath = Path.Combine(Path.GetTempPath(), "source.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.Text.StartsWith("00"))
{
result.Value = context.Text;
}
}
}
| Name | Description |
|---|---|
| Parse(CsvParseResult, CsvParseContext) | Parses cell text and lets you inspect or modify the result produced by the built-in parser. Use Text to inspect the original CSV text, and use Value or NumberFormat to customize the imported value. |