private AbstractValueSetter GetConvertorByType(Type dataType, FieldType fieldType, string format = null) { if (dataType == typeof(string)) { if (fieldType == FieldType.Text || fieldType == FieldType.Unknown) { return(new TextConvertor(p => (string)p)); } else if (fieldType == FieldType.Formula) { return(new FormulaConvertor(p => (string)p)); } } else if (ParseUtil.IsNumberType(dataType) && (fieldType == FieldType.Numeric || fieldType == FieldType.Unknown)) { //非Double类型用强制转换会报错,因此先转换成字符串,再转换成Double return(new NumericConvertor(p => double.Parse(p.ToString()), format)); } else if ((dataType == typeof(DateTime) || dataType == typeof(DateTime?)) && (fieldType == FieldType.Datetime || fieldType == FieldType.Unknown)) { return(new DateTimeConvertor(p => (DateTime)p, format)); } else if ((dataType == typeof(bool) || dataType == typeof(bool?)) && (fieldType == FieldType.Boolean || fieldType == FieldType.Unknown)) { return(new BooleanConvertor(p => (bool)p)); } else if ((dataType == typeof(byte) || dataType == typeof(byte?)) && fieldType == FieldType.Error) { return(new ErrorConvertor(p => (byte)p)); } else if (dataType == typeof(byte[]) && fieldType == FieldType.Picture) { return(new PictureConvertor(p => (byte[])p)); } return(null); }