When passed to .setValue it raises AttributeError: datetime object has no attribute getTypes.
Any datetime in a spreadsheet (Excel, Gnumeric, Calc, historic ones) is a floating point number counting days and fractions of days since day zero 1899-12-30 00:00:00
. Therefore, your Python program needs to calculate this difference between your wanted datetime and point zero on the time scale. Unlike Excel, Calc accepts negative day numbers until year 1. Spreadsheet functions (easterdate, weekday, month etc.) work reliably back until 1582-10-15 (start of Gregorian Calendar).
P.S. alternative method: oCell.setFormula(time.strftime('%Y-%m-%d %H:%M:%S')
which writes the ISO datetime string as a formula into the cell. Every cell has a formula string, regardless of content:
‘’ Empty string
‘123.987’
‘ABCDE’
‘=SUM(A1:B99)’
'‘12345’ numeric string with leading apostrophe.
Thank you, it looks very good and seems to be the correct approach. I’ll definitely try it later when I have more time and either read all the code or not in a situation where running unverified code is not allowed.