On 11/04/10 17:15, Scott Deerwester wrote:
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:

If UNO_DATE is from the com.sun.star.util.NumberFormat constants, this condition is wrong. The "NumberFormat" property contains keys, such as from the queryKey call above.

Also note that queryKey works only if the format is already present for the locale. Otherwise it returns -1 and you have to use addNew.

Niklas

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to