MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

关于空单元格无法转换DateTime的问题。

Open RRQM opened this issue 2 years ago • 1 comments

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

当单元格内容为空格时,就会转换失败。

我希望的解决方法:

  1. 如果是空格,或者其他无法转化的时候,可以使用default赋值默认。
  2. 或者新增一个Attribute,可以自定义转换器,这样也可以把时间样式也做成标签。

RRQM avatar Jun 19 '23 01:06 RRQM

你好,文件已过期,能否再提供一份文件

jiaguangli avatar Jun 11 '24 01:06 jiaguangli

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.

michelebastione avatar May 18 '25 17:05 michelebastione