diff --git a/src/MiniExcel/Utils/CustomPropertyHelper.cs b/src/MiniExcel/Utils/CustomPropertyHelper.cs index e6a0f60d271c29d0a132b1c80a18c832c20bffb8..7e8d24f1b600506fc61cc243feb548f0a457b24a 100644 --- a/src/MiniExcel/Utils/CustomPropertyHelper.cs +++ b/src/MiniExcel/Utils/CustomPropertyHelper.cs @@ -160,6 +160,8 @@ private static IEnumerable GetExcelPropertyInfo(Type ty { formatToStringMethod = excludeNullableType.GetMethod("ToString", new[] { typeof(string) }); } + //https://gitee.com/dotnetchina/MiniExcel/issues/I4TXGT + string dispName = p.GetCustomAttribute()?.DisplayName ?? ""; MethodInfo cultureToStringMethod = excludeNullableType.GetMethod("ToString", new[] { typeof(CultureInfo) }); return new ExcelCustomPropertyInfo { @@ -168,7 +170,7 @@ private static IEnumerable GetExcelPropertyInfo(Type ty ExcludeNullableType = excludeNullableType, Nullable = gt != null, ExcelColumnAliases = excelColumnName?.Aliases, - ExcelColumnName = excelColumnName?.ExcelColumnName ?? p.Name, + ExcelColumnName = excelColumnName?.ExcelColumnName ?? (dispName == "" ? p.Name : dispName), ExcelColumnIndex = p.GetAttribute()?.ExcelColumnIndex, ExcelColumnWidth = p.GetAttribute()?.ExcelColumnWidth, ExcelFormat = excelFormat,