OASIS Open Document Format for Office Applications (OpenDocument) TC

  • 1.  ODD{F,L}, Yield and Price spreadsheet functions.

    Posted 05-14-2008 22:06

    I had an action item to see if OOXML has good definitions for ODD{F,L}, Yield and Price spreadsheet functions.

    The final OOXML text is not available publicly, or even to JTC1 or SC34 participants, but I happened upon a copy, and what I'll report is based on this text of April 30th.

    The two functions ODDFPRICE and ODDLYIELD have full definitions, including a formula.  I have no idea whether this formula is correct (from a financial perspective) or whether it in fact reflects Microsoft Excel's calculations.  

    For example, ODDLYIELD is defined as:



    ODDFYIELD and ODDLPRICE  had useless definitions.  They just said something like  "Computes the price per $100 face value of a security having an odd (short or long) last coupon period", with no formula or reference given.

    To move forward on this we need to consider three possibly different definitions of any spreadsheet function:

    1) The correct formula, as determined by an external authority, perhaps another standard, or a standard textbook or handbook in the field.
    2) What Excel calculates.  This may differ in some cases with the external authority, for example with leap year calculations, or the definition of the CEILING function.
    3) The formula that OOXML provides.  We should not assume that this formula accurately reflects what Excel actually does.  In fact, using these definitions as a short cut to our own definitions is likely to lead us astray.

    I'll drill down more into these financial functions.   I've ordered some books on financial mathematics that should explain these and other mysteries of life.



    -Rob
    ___________________________

    Rob Weir
    Software Architect
    Workplace, Portal and Collaboration Software
    IBM Software Group

    email: robert_weir@us.ibm.com
    phone: 1-978-399-7122
    blog:
    http://www.robweir.com/blog/


  • 2.  Re: [office] ODD{F,L}, Yield and Price spreadsheet functions.

    Posted 05-14-2008 22:42
    Robert Weir:
    "To move forward on this we need to consider three possibly different
    definitions of any spreadsheet function:
    1) The correct formula, as determined by an external authority, perhaps
    another standard, or a standard textbook or handbook in the field.
    2) What Excel calculates.  This may differ in some cases with the
    external authority, for example with leap year calculations, or the
    definition of the CEILING function.
    3) The formula that OOXML provides.  We should not assume that this
    formula accurately reflects what Excel actually does.  In fact, using
    these definitions as a short cut to our own definitions is likely to lead
    us astray."
    
    Just to clarify for all, we've already addressed the examples of #2. Here's some basics on how we addressed them.
    
    CEILING is redefined to be a _superset_ of Excel's capabilities and the standard math operator (which Excel is not compatible with).  If you use a one-parameter version, you get the standard mathematical function (Excel doesn't have a 1-parameter version).  But through additional parameters you can say "please use the screwed-up Excel semantics".  Thus, CEILING _looks_ slightly different in OpenFormula, but it has all the capabilities of Excel _AND_ standard math _AND_ OpenOffice.org.  This is one of the few functions where translating between Excel and OpenFormula is slightly more than a syntax change and function rename, but it's still trivial.  The same holds for FLOOR, of course.
    
    The date stuff has been resolved after much discussion. Dates are stored as dates, not as numbers, which eliminates much of the epoch dependency and other weirdness in the first place.   OpenFormula is specifically designed to permit, but NOT require, a screwed-up leap year calculation in 1900.  (So you CAN do exactly what Excel does, if your users demand it, but you are not REQUIRED to get wrong results as the OXML spec mandates.) It also allows a different epoch value (Dec 31 1899) that resolves this weirdness in nearly all cases.  There's also a predefined "Year 1583" option: "An application having the “year 1583” capability can correctly calculate dates correctly starting from the January 1 of the (ISO) year 1583.  This means that the application correctly determines that 1900 was not a leap year, and can handle year values for dates back to at least 1583.  These calculations use the ISO (proleptic Gregorian) calendar, that is, the calculations simply use the usual rules for the ISO (Gregorian) calendar, regardless of locale."  While many countries did NOT use Gregorian in 1583, pretending that everyone DID is actually helpful because it provides a single, uniform measurement system that you can correct other locales to.   It's trivial to implement, so it's a reasonable thing to ask implementors to do.  Year 1583 is merely an option, because many people don't need it, but by including the option in the spec, we'll probably increase the number of implementors that implement it (and thus increase interoperability).  Excel can't handle dates before 1900.
    
    --- David A. Wheeler
    


  • 3.  Re: [office] ODD{F,L}, Yield and Price spreadsheet functions.

    Posted 05-15-2008 04:48
    On Wed, 2008-05-14 at 18:41 -0400, David A. Wheeler wrote:
    > The date stuff has been resolved after much discussion. Dates are
    > stored as dates, not as numbers, which eliminates much of the epoch
    > dependency and other weirdness in the first place. 
    
    Is there any descriptions somewhere how this is supposed to work in the
    context of importing files from other common formats?
    
    Imagine: [.A1]      34556
             [.A2]      56643
             [.A3]      =[.A1] - 3 * [.A2]
             [.A4]      =DAYS360([.A1];[.A2])
             
    
    You may want to argue that this is not a sensible spreadsheet and I
    would likely agree but I have see much stranger constructions in
    existing XL spreadsheets.
    
    How would you export such a spreadsheet into OpenFormula?
    
    Andreas
    -- 
    Andreas J. Guelzow 


  • 4.  Re: [office] ODD{F,L}, Yield and Price spreadsheet functions.

    Posted 05-15-2008 13:45


    "Andreas J. Guelzow" <aguelzow@math.concordia.ab.ca> wrote on 05/15/2008 12:48:07 AM:

    > Is there any descriptions somewhere how this is supposed to work in the
    > context of importing files from other common formats?
    >
    > Imagine: [.A1]      34556
    >          [.A2]      56643
    >          [.A3]      =[.A1] - 3 * [.A2]
    >          [.A4]      =DAYS360([.A1];[.A2])

    The only interesting thing here is in A4, where there is an implicit conversion from a number to a date.  The other calculations are purely numeric.

    Excel will do this conversion differently based on whether the spreadsheet is in 1900-mode or 1904-mode.  This was originally a Windows versus Mac distinction.

    OOXML has a different set of modes:

    1900 date base system -- expresses years from -9999 to 99999 with origin at December 30th, 1899 = 0

    1900 backward compatibility system -- expresses years from 1900 to 9999 with January 1st, 1900 = 1 (default system)

    1904 backwards compatibility system -- expresses years from 1904 to 9999 with January 1st, 1904  = 0.

    Only the default mode is implemented in Excel 2007.

    So realistically, all a convertor needs to worry about today is the 1900/1904 distinction.

    An ODF table (including a spreadsheet) allows a table:null-date element that specifies the date original, i.e., what date is equivalent to the number 0.  The default value is 1899-12-30.  So this would be the same as the 1900 date base system in OOXML.

    So in the case of importing an existing Excel document, the easiest thing for a convertor to do would be to set the table:null-date value in the ODF document to correspond to the conventions used by the source Excel document.

    The hard case would be when importing content from multiple source Excel documents into a single ODF document, say one using 1900 conventions, one using 1904 conventions, one using OOXML conventions, etc.  I don't think this works even if you did it all in Excel.  

    Generally, relying on the details of implementation's numeric-to-date conversions will result in a non-portable document.  

    -Rob


  • 5.  Re: [office] ODD{F,L}, Yield and Price spreadsheet functions.

    Posted 05-16-2008 02:04
    And if one wants to update a document to use another convention, how
    would the user change the table:null-date value? Is this something
    that would appear in the format dialogs?
    
    wt
    
    On Thu, May 15, 2008 at 6:45 AM,  


  • 6.  Re: [office] ODD{F,L}, Yield and Price spreadsheet functions.

    Posted 05-16-2008 15:32

    "Warren Turkal" <turkal@google.com> wrote on 05/15/2008 10:03:36 PM:

    > And if one wants to update a document to use another convention, how
    > would the user change the table:null-date value? Is this something
    > that would appear in the format dialogs?
    >

    Typically this is an document-wide setting.  Excel has it in the Tools\Options\Calculation dialog.  OpenOffice puts the setting in Tools\Options\OpenOffice.org Calc\Calculate.

    But note that changing this setting does not automatically shift values around so dates remains consistent.  If you have January 1st 1900 as your date origin, and then switch to 1904 origin, then any date calculation that operated on numeric data will be shifted 4 years forward.

    -Rob