calamine icon indicating copy to clipboard operation
calamine copied to clipboard

ODS: extract error value from cell

Open dimastbk opened this issue 2 years ago • 3 comments

ODS doesn't support errors as a type, and stores errors as text, which depends on locale and application. And, I think, it should have higher priority, that extracting value from office:value (<table:table-cell office:value-type="float" office:value="0" table:formula="of:=#N/A" table:style-name="ce1"><text:p>#N/A</text:p></table:table-cell>).

LibreOffice: image

Microsoft Office Online: image

dimastbk avatar Sep 08 '23 04:09 dimastbk

Hi, I'm not sure what you're suggesting? Where did you find information about the actual behavior (about locale etc)?

tafia avatar Sep 12 '23 02:09 tafia

I saved example file using LibreOffice with deutsche interface - errors_de.ods. There is part of content.xml of this file below:

<table:table table:name="Sheet1" table:style-name="ta1"><table:table-column table:style-name="co1"
        table:default-cell-style-name="Default" /><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=1/0" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#DIV/0!</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=NA()" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#NV</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=xyz/3" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#NAME?</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=SUM([.B1] [.C1])" office:value-type="string" office:string-value=""
            calcext:value-type="error">
            <text:p>Fehler:509</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=ASIN(123)" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#ZAHL!</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=OFFSET([.A1];0;20000)" office:value-type="string" office:string-value=""
            calcext:value-type="error">
            <text:p>Fehler:502</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=1+&quot;ABC&quot;" office:value-type="string" office:string-value=""
            calcext:value-type="error">
            <text:p>#WERT!</text:p>
        </table:table-cell></table:table-row></table:table>

and with english interface - errors_en.ods:

<table:table table:name="Sheet1" table:style-name="ta1"><table:table-column table:style-name="co1"
        table:default-cell-style-name="Default" /><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=1/0" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#DIV/0!</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=NA()" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#N/A</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=xyz/3" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#NAME?</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=SUM([.B1] [.C1])" office:value-type="string" office:string-value=""
            calcext:value-type="error">
            <text:p>Err:509</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=ASIN(123)" office:value-type="string" office:string-value="" calcext:value-type="error">
            <text:p>#NUM!</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=OFFSET([.A1];0;20000)" office:value-type="string" office:string-value=""
            calcext:value-type="error">
            <text:p>Err:502</text:p>
        </table:table-cell></table:table-row><table:table-row table:style-name="ro1"><table:table-cell
            table:formula="of:=1+&quot;ABC&quot;" office:value-type="string" office:string-value=""
            calcext:value-type="error">
            <text:p>#VALUE!</text:p>
        </table:table-cell></table:table-row></table:table>

(#ZAHL! and #NUM!, #WERT! and #VALUE!). Also, as I see, LibreOffice and Excel use different codes in some cases (Err:502 and #REF!, for example).

Hi, I'm not sure what you're suggesting?

I don't know. I see only one decision: store all localized values of errors and check text value of cell if table:formula is presented, but I think it will be bad for performance.

dimastbk avatar Sep 12 '23 06:09 dimastbk

I see only one decision: store all localized values of errors and check text value of cell if table:formula is presented, but I think it will be bad for performance.

I think we can always have feature flag to mitigate performance:

const N_ERR: usize = 7; // can't remember how many of them we have
const ODS_LOCALE_ERR: &[[&'str; N_ERR]] = &[
    #[cfg(feature = "ods-err-us")]
    [....],
    #[cfg(feature = "ods-err-de")]
    [....],
]

And default to only have ods-err-us?

tafia avatar Sep 12 '23 08:09 tafia