예제 #1
0
        private static XLDataType GetDataType <T>(ICsvColumn <T> column)
        {
            switch (column.DataType)
            {
            case ColumnDataType.Number:
            case ColumnDataType.Decimal:
                return(XLDataType.Number);

            case ColumnDataType.DateTime:
                return(XLDataType.DateTime);

            case ColumnDataType.Boolean:
                return(XLDataType.Boolean);

            case ColumnDataType.Time:
                //return XLDataType.Text;
                return(XLDataType.TimeSpan);

            case ColumnDataType.Currency:
                return(XLDataType.Number);

            case ColumnDataType.Text:
            case ColumnDataType.Composite:
            case ColumnDataType.StrongTyped:
            case ColumnDataType.Object:
            case ColumnDataType.Dynamic:
                return(XLDataType.Text);

            default:
                return(XLDataType.Text);
            }
        }
예제 #2
0
        private void SetPropertyValue(TRow row, ICsvColumn <TRow> column, CsvLine line, string element)
        {
            PropertyInfo prop = typeof(TRow).GetProperty(column.PropertyName);

            if (!this.Definition.IgnoreReadonlyProperties && !prop.CanWrite)
            {
                throw new CsvStreamMapperException("The field '" + column.PropertyName + "' is readonly (e.g. is not writable).", line);
            }
            if (prop.CanWrite)
            {
                prop.SetValue(row, Conversion.AsValue(prop.PropertyType, element, Definition.FormattingCulture), null);
            }
        }
예제 #3
0
 private IEnumerable <string> GetHeaderNames <T>(CsvDefinition <T> definition, ICsvColumn <T> column, T[] rows)
 {
     return(column.GetWritingHeaderNames(rows).Select(header => GetColumnHeaderWithoutEnters(header)));
 }
예제 #4
0
 private static HeaderCollection GetHeaderNames <T>(CsvDefinition <T> definition, ICsvColumn <T> column, T[] rows)
 {
     return(column.GetWritingHeaderNames(rows));
 }