【问题标题】:Converting to Date format shows #VALUE! in Excel rdlc report转换为日期格式显示#VALUE!在 Excel rdlc 报告中
【发布时间】:2016-08-17 15:13:10
【问题描述】:

我正在尝试从 RDLC 报告生成 excel 文件,其中报告表中的列将字符串值转换为 DateTime,如下所示

=IIF(Fields!WeldDate.Value is nothing, nothing, Format(CDate(Fields!WeldDate.Value).ToString("dd/MM/yyyy")))

如果 WeldDate 为空字符串,则 Excel 数据显示 #VALUE!。我该如何解决这个问题?

P.S: 下面我也试过了。

=IIF(Fields!WeldDate.Value is "", "", Format(CDate(Fields!WeldDate.Value).ToString("dd/MM/yyyy")))

【问题讨论】:

  • 但我有一个 if 条件。如果日期值是 nothing/"" 则不返回任何内容或 ""
  • 但是当我在 Excel 中看到该列的列类型时,它仍然显示为“常规”而不是日期
  • #Value!表示值错误
  • 在 VBA 中,IIf 函数总是计算 true_partfalse_part。如果其中任何一个都可能返回错误,则需要使用 If ...Then ... Else ... End If 结构。这可能是您的语言中的同一个问题吗?

标签: c# .net wpf excel rdlc


【解决方案1】:

试试这个:

=IIf(Len(Fields!WeldDate.Value) > 0, Format(CDate(Fields!WeldDate.Value), "dd/MM/yyyy"), "")

或者看看这个,这似乎是一个非常相似的问题:
Formatting null time in RDLC report

【讨论】:

  • 显示相同的结果
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多