Formatted value of a Calc date cell?

Scott Deerwester <[email protected]>
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
I'm having trouble understanding how to get the formatted value of a date
cell. I'm using the PyUNO binding of the API, and trying to reformat a date
cell as YYYY-MM-DD. Here's (a somewhat slimmed down version of) the relevant
portion of the code, with various things I've tried in comments.

    locale = document.getPropertyValue("CharLocale")
    formats = document.getNumberFormats()
    formatID = formats.queryKey("YYYY-MM-DD", locale, False)
    line = []

    for r in range(dataRange.StartRow, dataRange.EndRow):
        for c in range(dataRange.StartColumn, dataRange.EndColumn):
            cell = sheet.getCellByPosition(c,r)
            cellType = cell.getType()

            if cellType == UNO_VALUE and cell.NumberFormat == UNO_DATE:
                cell.NumberFormat = formatID
                line.append(cell.getText().String)
                # line.append(cell.String)
                # line.append(cell.getString())
                # line.append(cell.Value)
                # line.append(cell.getValue())
                # line.append(cell.Formula)

All of the above give me floating point numbers instead of a date. I've also
tried displaying the value without changing the format. What am I missing?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.