MiniExcel
MiniExcel copied to clipboard
关于空单元格无法转换DateTime的问题。
Excel Type
- [x] XLSX
- [ ] XLSM
- [ ] CSV
- [ ] OTHER
Upload Excel File
Please attach your issue file by dragging or droppng, selecting or pasting them.
https://t.wss.ink/f/bhn14t73oub
MiniExcel Version
v1.31.0
Description
当单元格内容为空格时,就会转换失败。
我希望的解决方法:
- 如果是空格,或者其他无法转化的时候,可以使用default赋值默认。
- 或者新增一个Attribute,可以自定义转换器,这样也可以把时间样式也做成标签。
你好,文件已过期,能否再提供一份文件
You can easily do that by using nullable types associated with readonly propertie:
class ExampleClass
{
public DateTime? PotentialInvalidDate { get; set; }
public DateTime ValidDateOrDefault => PotentialInvalidDate ?? default;
}
This holds true also for DateTimeOffset, DateOnly, TimeSpan and Guid.