donnytian / Npoi.Mapper

Use this tool to import or export data with Excel file. The tool is a convention based mapper between strong typed object and Excel data via NPOI.
MIT License
589 stars 114 forks source link

Unable to map date to DateOnly datatype #137

Open rasupit opened 4 months ago

rasupit commented 4 months ago

Mapping to DateOnly data type is not working or at least it can be done is not so straight forward way.

My current work around as follows: `

            mapper.Map<FeedSapTivBill>("Invoice date", r => r.InvoiceDate, (s, t) => {
                if (s.HeaderValue == null) return false;

                ((FeedSapTivBill)t).InvoiceDate = DateOnly.FromDateTime((DateTime)s.CurrentValue);
                return true;
            }

It will be nice if it will work outomatically

dcjxdd123 commented 4 months ago

you already get Exact DateTime

rasupit commented 4 months ago

you already get Exact DateTime

Yes, however I'm mapping it to DateOnly type, therefore I have to convert the value to DateOnly. In this example is from datetime