tafia / calamine

A pure Rust Excel/OpenDocument SpreadSheets file reader: rust on metal sheets
MIT License
1.6k stars 155 forks source link

ODS: extract error value from cell #355

Open dimastbk opened 10 months ago

dimastbk commented 10 months ago

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

tafia commented 9 months ago

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

dimastbk commented 9 months ago

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

```xml #DIV/0! #NV #NAME? Fehler:509 #ZAHL! Fehler:502 #WERT! ```

and with english interface - errors_en.ods:

```xml #DIV/0! #N/A #NAME? Err:509 #NUM! Err:502 #VALUE! ```

(#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.

tafia commented 9 months ago

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?