[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.CsvParseResult

CsvParseResult Class

Represents the parsed CSV value and its number format.

A custom ICsvParser can inspect or modify this result to preserve leading zeros, convert text to another supported value, or assign a number format for the imported cell.

Inheritance
CsvParseResult
Namespace: GrapeCity.Documents.Excel
Assembly: DS.Documents.Excel.dll
Syntax
public class CsvParseResult
Public Class CsvParseResult
Examples
CsvOpenOptions options = new CsvOpenOptions();
options.Parser = new PercentParser();
string filePath = Path.Combine(Path.GetTempPath(), "percentage.csv");
File.WriteAllText(filePath, "Value\n15%");
workbook.Open(filePath, options);
IWorksheet activeSheet = workbook.ActiveSheet;

class PercentParser : ICsvParser
{
    public void Parse(CsvParseResult result, CsvParseContext context)
    {
        if (context.Text.EndsWith("%"))
        {
            string text = context.Text.Replace("%", "");
            result.Value = double.Parse(text) / 100;
            result.NumberFormat = "0%";
        }
    }
}

Properties

Name Description
NumberFormat

Gets or sets the parsed number format.

Value

Gets or sets the parsed value.

The value should be double, string, bool, or CalcError. Other values are discarded.