ExcelMapper icon indicating copy to clipboard operation
ExcelMapper copied to clipboard

How Handling Missing Excel Headers in Model Mapping?

Open junjielyu13 opened this issue 9 months ago • 0 comments

I had a problem. When I want to map an Excel to a model, and Excel is missing a some header or colum, the mapping will be error.

How can I solve this problem?

there is sample:

hasFinish = !sheet.TryReadRow(out ChargesModelRow row);

public partial record ChargesModelRow : IEqualityYieldCompare
{

...
     [ExcelColumnIndex(15)]
     public IEnumerable<CriteriaEnum> Criteria { get; set; } = new List<CriteriaEnum>();
     public PaymentTypeEnum? PaymentType { get; set; }
    
     public Guid? GroupId { get; init; } = null;
"

For example, in this case, I added GroupId in ChargesModelRow, but if excel does not exist this colum, will be error . How can I solve this problem?

junjielyu13 avatar May 24 '24 11:05 junjielyu13