mganss / ExcelMapper

An Excel to object mapper. Maps POCOs to and from Excel. Configuration via convention, attributes, or fluent methods.
MIT License
793 stars 122 forks source link

valueparser not work when call Fetch() function #289

Open yangzhixiao opened 9 months ago

yangzhixiao commented 9 months ago

valueparser will not callback Platform: net 8.0

mganss commented 9 months ago

Can you provide a code snippet that shows the issue?

yangzhixiao commented 9 months ago

Can you provide a code snippet that shows the issue?

Func<string, object, object> parser = (key, value) =>
{
    if (value is string s && s.Contains(",") && s.Split(",").All(x => int.TryParse(x, out int _)))
        return new Point(int.Parse(s.Split(",")[0]), int.Parse(s.Split(",")[1]));
    return value;
};
ExcelMapper excelMapper = new ExcelMapper();
excelMapper.Save("Config.xlsx", mapInfos, "MapInfo", true, converter);
mganss commented 9 months ago

I can't repro. In your example the Func variable is called parser but you're passing a different variable named converter to the Save method. Could that be the cause?