Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Input string was not in a correct format. #241

Closed
taoqijing opened this issue Feb 23, 2021 · 6 comments
Closed

Input string was not in a correct format. #241

taoqijing opened this issue Feb 23, 2021 · 6 comments
Labels

Comments

@taoqijing
Copy link

您好,打扰了.
项目升级到net5.0之后,导出功能出现错误提示,枚举类型
Input string was not in a correct format.Couldn't store <公交车> in CarType Column. Expected type is EnumCarType.
版本:最新版2.5.1.7

@hueifeng hueifeng added the area-excel excel label Feb 23, 2021
@hueifeng
Copy link
Member

@taoqijing Can you provide the data? I need to duplicate this problem.

@taoqijing
Copy link
Author

//文件导出类
[ExcelExporter(Name = "车辆信息表", TableStyle = OfficeOpenXml.Table.TableStyles.Light8, AutoFitAllColumn = true, MaxRowNumberOnASheet = 2000)]
public class CarInfoExcelDto
{
///


/// 车牌号
///

[ImporterHeader(Name = "车牌号")]
[ExporterHeader(DisplayName = "车牌号")]
[Required(ErrorMessage = "车牌号不能为空")]
public string CarNum { get; set; }

    /// <summary>
    /// 所属组织机构
    /// </summary>   
    [ImporterHeader(Name = "所属组织机构")]
    [ExporterHeader(DisplayName = "所属组织机构")]
    [Required(ErrorMessage = "所属组织机构不能为空")]
    public string OrgName { get; set; }
    /// <summary>
    /// 定位设备id
    /// </summary>   
    [ImporterHeader(Name = "定位设备")]
    [ExporterHeader(DisplayName = "定位设备")]
    public string GpsEquipNum { get; set; }
    /// <summary>
    /// 通讯设备id
    /// </summary>  
    [ImporterHeader(Name = "通讯设备")]
    [ExporterHeader(DisplayName = "通讯设备")]
    public string TelephonyNum { get; set; }

    /// <summary>
    /// 车辆类型
    /// </summary>   
    [ImporterHeader(Name = "车辆类型")]
    [ExporterHeader(DisplayName = "车辆类型")]
    [Required(ErrorMessage = "车辆类型不能为空")]
    public EnumCarType? CarType { get; set; }
}



//   车辆类型
public enum EnumCarType
{
    [Description("未知")]
    未知 = 0,
    [Description("垃圾车")]
    垃圾车 = 1,        
    [Description("工作车")]
    工作车 = 2
}

@hueifeng
Copy link
Member

@taoqijing Close issue? Does it need to be reopened?

@taoqijing
Copy link
Author

点错了,抱歉

@taoqijing taoqijing reopened this Feb 23, 2021
@hueifeng
Copy link
Member

hueifeng commented Feb 23, 2021

You can upgrade to the latest version.

dotnet add package Magicodes.IE.Excel --version 2.5.1.8

@taoqijing
Copy link
Author

非常感谢!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants