[Solved] Write cell as string turns date to string

Creating a macro - Writing a Script - Using the API

[Solved] Write cell as string turns date to string

Postby MaxG » Sun Jan 20, 2019 1:19 am

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   Expand viewCollapse view
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   Expand viewCollapse view
    ' 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
MaxG
 
Posts: 13
Joined: Fri Jan 18, 2019 8:00 am

Re: write cell as string turns date to string

Postby Villeroy » Sun Jan 20, 2019 1:37 am

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27583
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: write cell as string turns date to string

Postby MaxG » Sun Jan 20, 2019 1:45 am

Thanks @Villeroy... further digging also revealed one of your posts:
Re: Setting date from macro to cell
OpenOffice 4.1.5 on Windows 10
MaxG
 
Posts: 13
Joined: Fri Jan 18, 2019 8:00 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests