Skip to content

Commit b0e983e

Browse files
committed
support IEnumerable data
1 parent 4b03e42 commit b0e983e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/MiniExcel/Utils/CustomPropertyHelper.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,9 @@ private static IEnumerable<ExcelColumnInfo> ConvertToExcelCustomPropertyInfo(Pro
183183
var excludeNullableType = gt ?? p.PropertyType;
184184
var excelFormat = p.GetAttribute<ExcelFormatAttribute>()?.Format;
185185
var excelColumn = p.GetAttribute<ExcelColumnAttribute>();
186-
if (configuration.DynamicColumns != null && configuration.DynamicColumns.Length > 0)
187-
{
188-
var dynamicColumn = configuration.DynamicColumns.SingleOrDefault(_ => _.Key == p.Name);
189-
if (dynamicColumn != null)
190-
excelColumn = dynamicColumn;
191-
}
186+
var dynamicColumn = configuration?.DynamicColumns?.SingleOrDefault(_ => _.Key == p.Name);
187+
if (dynamicColumn != null)
188+
excelColumn = dynamicColumn;
192189

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

0 commit comments

Comments
 (0)