[Solved] Write cell as string turns date to string

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
MaxG
Posts: 13
Joined: Fri Jan 18, 2019 8:00 am

[Solved] Write cell as string turns date to string

Post by MaxG »

I am reading a line of text delimited by tabs inot an array, which I write to a row in a spreadsheet.
The data starts with a date and the rest of the fields are numbers... like so:

Code: Select all

19/01/2019	51.1	26.43	10.28
When I write the cell as number only the day (19) is placed in the cell.
When I write the call as String, the date is written as string ('19/01/2019) and not as date.

Code: Select all

    ' loop through text line array
    If i <> 0 then
      ' write all cells as number
      cell.Value = arrCurrentLine(i)
    Else
      ' write first cell as String
      cell.String = arrCurrentLine(i)
    End If
I could not find a date type for a cell.
How can I write the date as a date to the cell?
Any hints appreciated.
Last edited by MaxG on Sun Jan 20, 2019 1:46 am, edited 1 time in total.
OpenOffice 4.1.5 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: write cell as string turns date to string

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
MaxG
Posts: 13
Joined: Fri Jan 18, 2019 8:00 am

Re: write cell as string turns date to string

Post by MaxG »

Thanks @Villeroy... further digging also revealed one of your posts:
Re: Setting date from macro to cell
OpenOffice 4.1.5 on Windows 10
Post Reply