Skip to content

Commit

Permalink
fix #214
Browse files Browse the repository at this point in the history
  • Loading branch information
hueifeng committed Feb 19, 2021
1 parent 5457cc1 commit c01be8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ImporterHeaderInfo

/// <summary>
/// </summary>
public Dictionary<string, dynamic> MappingValues { get; set; } = new Dictionary<string, dynamic>();
public Dictionary<string, dynamic> MappingValues { get; set; } = new Dictionary<string, dynamic>(W);

/// <summary>
/// 是否存在
Expand Down
13 changes: 11 additions & 2 deletions src/Magicodes.ExporterAndImporter.Excel/Utility/ImportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ protected virtual void ParseData(ExcelPackage excelPackage)
var cellValue = cell.Value?.ToString();
if (!cellValue.IsNullOrWhiteSpace())
{
if (col.MappingValues.Count > 0 && col.MappingValues.ContainsKey(cellValue))
if (col.MappingValues.Count > 0 &&
(col.MappingValues.ContainsKey(cellValue)))
{
//TODO:进一步缓存并优化
var isEnum = propertyInfo.PropertyType.IsEnum;
Expand All @@ -1025,9 +1026,17 @@ protected virtual void ParseData(ExcelPackage excelPackage)
propertyInfo.SetValue(dataItem,
value);
}

continue;
}
else
{
if (int.TryParse(cellValue, out int result))
{
propertyInfo.SetValue(dataItem,
result);
continue;
}
}
}
else
{
Expand Down

0 comments on commit c01be8b

Please sign in to comment.