[gnumeric] xlsx: handle missing values.



commit 21e545833a25ce67064e6de434c1d67036283c29
Author: Morten Welinder <terra gnome org>
Date:   Sat Aug 22 22:00:10 2020 -0400

    xlsx: handle missing values.
    
    Formulas with missing values aren't valid xlsx, but occur in the wild.
    Mark them for recalc.

 NEWS                      |  1 +
 plugins/excel/xlsx-read.c | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5db632409..b8d819362 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.12.49
 Morten:
        * Rework conditional styling's upper level.
        * Fix autofill array critical.  [#511]
+       * Handle missing values in xlsx.  [#517]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.48
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 248dd93c5..ff0b11fb6 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -1331,10 +1331,15 @@ xlsx_cell_val_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
        char            *end;
        long             i;
 
+       if (*xin->content->str == 0) {
+               // See #517
+               state->val = value_new_empty ();
+               return;
+       }
+
        switch (state->pos_type) {
        case XLXS_TYPE_NUM :
-               if (*xin->content->str)
-                       state->val = value_new_float (gnm_strto (xin->content->str, &end));
+               state->val = value_new_float (gnm_strto (xin->content->str, &end));
                break;
        case XLXS_TYPE_SST_STR :
                i = xlsx_relaxed_strtol (xin->content->str, &end, 10);
@@ -1537,6 +1542,11 @@ xlsx_cell_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
        } else if (NULL != state->val)
                gnm_cell_assign_value (cell, state->val);
 
+       // We use an empty value as an indicator for "no value"
+       if (VALUE_IS_EMPTY (state->val)) {
+               cell_queue_recalc (cell);
+       }
+
        state->texpr = NULL;
        state->val = NULL;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]