Skip to content

Commit

Permalink
support IEnumerable data
Browse files Browse the repository at this point in the history
  • Loading branch information
izanhzh committed Jan 23, 2025
1 parent 4b03e42 commit b0e983e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/MiniExcel/Utils/CustomPropertyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,9 @@ private static IEnumerable<ExcelColumnInfo> ConvertToExcelCustomPropertyInfo(Pro
var excludeNullableType = gt ?? p.PropertyType;
var excelFormat = p.GetAttribute<ExcelFormatAttribute>()?.Format;
var excelColumn = p.GetAttribute<ExcelColumnAttribute>();
if (configuration.DynamicColumns != null && configuration.DynamicColumns.Length > 0)
{
var dynamicColumn = configuration.DynamicColumns.SingleOrDefault(_ => _.Key == p.Name);
if (dynamicColumn != null)
excelColumn = dynamicColumn;
}
var dynamicColumn = configuration?.DynamicColumns?.SingleOrDefault(_ => _.Key == p.Name);
if (dynamicColumn != null)
excelColumn = dynamicColumn;

var ignore = p.GetAttributeValue((ExcelIgnoreAttribute x) => x.ExcelIgnore) || p.GetAttributeValue((ExcelColumnAttribute x) => x.Ignore) || (excelColumn != null && excelColumn.Ignore);
if (ignore)
Expand All @@ -209,7 +206,8 @@ private static IEnumerable<ExcelColumnInfo> ConvertToExcelCustomPropertyInfo(Pro
ExcelColumnWidth = p.GetAttribute<ExcelColumnWidthAttribute>()?.ExcelColumnWidth ?? excelColumn?.Width,
ExcelFormat = excelFormat ?? excelColumn?.Format,
ExcelFormatId = excelColumn?.FormatId ?? -1,
ExcelColumnType = excelColumn?.Type ?? ColumnType.Value
ExcelColumnType = excelColumn?.Type ?? ColumnType.Value,
CustomFormatter = dynamicColumn?.CustomFormatter
};
}).Where(_ => _ != null);
}
Expand Down

0 comments on commit b0e983e

Please sign in to comment.