diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index c3e1e6c543..c929d10c56 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -992,14 +992,8 @@ std::string Cell::getFormattedQuantity(void) } } - } else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()) || - prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - double rawVal; - if(prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - rawVal = static_cast(prop)->getValue(); - } else { - rawVal = static_cast(prop)->getValue(); - } + } else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())){ + double rawVal = static_cast(prop)->getValue(); DisplayUnit du; bool hasDisplayUnit = getDisplayUnit(du); double duScale = du.scaler; @@ -1008,6 +1002,17 @@ std::string Cell::getFormattedQuantity(void) QString number = QLocale::system().toString(rawVal / duScale, 'f',Base::UnitsApi::getDecimals()); qFormatted = number + Base::Tools::fromStdString(" " + displayUnit.stringRep); } + } else if (prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + double rawVal = static_cast(prop)->getValue(); + DisplayUnit du; + bool hasDisplayUnit = getDisplayUnit(du); + double duScale = du.scaler; + int iRawVal = std::round(rawVal); + qFormatted = QLocale::system().toString(iRawVal); + if (hasDisplayUnit) { + QString number = QLocale::system().toString(rawVal / duScale, 'f',Base::UnitsApi::getDecimals()); + qFormatted = number + Base::Tools::fromStdString(" " + displayUnit.stringRep); + } } result = Base::Tools::toStdString(qFormatted); return result;