.setDataArray() fails with array members of type “Date”.
BASIC runtime error.
Object variable not set.
Is this intended behavior or a bug?
What is the BKM for setting array of cells from variant array with both date and string data type members?
Work around is to use .setData() or convert date to a long. Both of which have other undesireable side effects.
.setData() outputs strings as the value 0.
Converting date to long requires the cell/column be formated as date. Not such a big deal, except then other consumers of the date cell/column have to be changed to handle it as a long rather than a date.
REM ***** BASIC *****
Sub Main
Dim arrVariant(1 to 1, 1 to 3) As Variant
Dim date_x As Date: date_x = "2023-03-28"
Dim long_x As Long: long_x = 2000000000
Dim string_x As String: string_x = "This is a string"
arrVariant(1,1) = date_x
' arrVariant(1,1) = CLng(date_x)
arrVariant(1,2) = long_x
arrVariant(1,3) = string_x
ThisComponent.Sheets.getByName("Sheet1").getCellRangeByName("A1:C1").setDataArray(arrVariant)
End Sub