我们需要处理来自不同来源(地理位置)的数据Feed并以标准格式加载。 我们在处理Excel日期格式时遇到困难。
Private Function myFormat(ob As Range)
If (IsDate(ob)) Then
' Most times a date is a date but sometimes in excel numbers that are formatted may also return true for IsDate()
' To avoid this case force the conversion to a number and see if it matches. If it does then it's really a number and not a date.
If (Val(ob) = ob) Then
' it's really a number
myFormat = CStr(ob.Value)
Else
myFormat = Format(ob.Value, "YYYY-MM-DD")
End If
Else
If (InStr(ob.Value, ",") > 0) Then ' we must quote any string with a comma
myFormat = Chr(34) & CStr(ob.Value) & Chr(34)
Else
myFormat = CStr(ob.Value)
End If
If (InStr(ob.Value, """") > 0) Then ' we must escape an embedded "'s as well as quote the whole string
myFormat = Chr(34) & Replace(myFormat, Chr(34), Chr(34) & Chr(34)) & Chr(34)
End If
End If
End Function
问题:它无法将日期格式处理为dd.mm.yyyy [将其视为字符串]。
我搜索了论坛,但无法使用vb代码获得明确的解决方案。
快速帮助将受到高度赞赏!
最诚挚的问候, 斯瓦特