diff options
-rw-r--r-- | sc/source/filter/oox/sheetdatabuffer.cxx | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index 67c768c0a10a..93bfb74c473b 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -48,6 +48,7 @@ #include "documentimport.hxx" #include "formulabuffer.hxx" #include <numformat.hxx> +#include <sax/tools/converter.hxx> namespace oox { namespace xls { @@ -206,15 +207,17 @@ void SheetDataBuffer::setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCod void SheetDataBuffer::setDateCell( const CellModel& rModel, const OUString& rDateString ) { - ScDocument& rDoc = getScDocument(); - SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); - - double fValue = 0.0; - sal_uInt32 nFormatIndex = 0; - bool bValid = pFormatter->IsNumberFormat( rDateString, nFormatIndex, fValue ); + css::util::DateTime aDateTime; + if (!sax::Converter::parseDateTime( aDateTime, nullptr, rDateString)) + { + SAL_WARN("sc.filter", "SheetDataBuffer::setDateCell - could not parse: " << rDateString); + // At least don't lose data. + setStringCell( rModel, rDateString); + return; + } - if(bValid) - setValueCell( rModel, fValue ); + double fSerial = getUnitConverter().calcSerialFromDateTime( aDateTime); + setValueCell( rModel, fSerial); } void SheetDataBuffer::createSharedFormula(const ScAddress& rAddr, const ApiTokenSequence& rTokens) |