mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-16 04:42:53 +08:00
test
This commit is contained in:
parent
74c0814d75
commit
ab5ad121fe
@ -184,10 +184,25 @@ CellFormula Cell::formula() const
|
||||
bool Cell::isDateTime() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
if (d->cellType == NumberType && d->value.toDouble() >=0
|
||||
&& d->format.isValid() && d->format.isDateTimeFormat()) {
|
||||
|
||||
Cell::CellType cellType = d->cellType;
|
||||
double dValue = d->value.toDouble();
|
||||
QString strValue = d->value.toString().toUtf8();
|
||||
bool isValidFormat = d->format.isValid();
|
||||
bool isDateTimeFormat = d->format.isDateTimeFormat();
|
||||
|
||||
// NOTICE: google spreadsheet data is not adoptable.
|
||||
// cell style(10): cellType is SharedStringType. strValue is '1900. 1. 9'.
|
||||
// cell style(12): cellType is SharedStringType. strValue is '1900. 1. 11 AM 12:00:00'.
|
||||
|
||||
if ( cellType == NumberType &&
|
||||
dValue >= 0 &&
|
||||
isValidFormat &&
|
||||
isDateTimeFormat )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1941,7 +1941,7 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
}
|
||||
|
||||
}
|
||||
else if (reader.name() == QLatin1String("c"))
|
||||
else if (reader.name() == QLatin1String("c")) // Cell
|
||||
{
|
||||
//Cell
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
@ -1950,10 +1950,12 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
|
||||
//get format
|
||||
Format format;
|
||||
if (attributes.hasAttribute(QLatin1String("s")))
|
||||
int styleIndex = -1;
|
||||
if (attributes.hasAttribute(QLatin1String("s"))) // Style
|
||||
{
|
||||
//"s" == style index
|
||||
int idx = attributes.value(QLatin1String("s")).toString().toInt();
|
||||
styleIndex = idx;
|
||||
format = workbook->styles()->xfFormat(idx);
|
||||
|
||||
////Empty format exists in styles xf table of real .xlsx files, see issue #65.
|
||||
@ -1962,11 +1964,20 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
}
|
||||
|
||||
Cell::CellType cellType = Cell::NumberType;
|
||||
if (attributes.hasAttribute(QLatin1String("t")))
|
||||
if (attributes.hasAttribute(QLatin1String("t"))) // Type
|
||||
{
|
||||
QString typeString = attributes.value(QLatin1String("t")).toString();
|
||||
if (typeString == QLatin1String("s"))
|
||||
cellType = Cell::SharedStringType;
|
||||
{
|
||||
cellType = Cell::SharedStringType;
|
||||
|
||||
// NOTICE: somtimes 's' is not string type. it may be date-time type.
|
||||
if ( styleIndex == 10 ||
|
||||
styleIndex == 12 )
|
||||
{
|
||||
cellType = Cell::NumberType;
|
||||
}
|
||||
}
|
||||
else if (typeString == QLatin1String("inlineStr"))
|
||||
cellType = Cell::InlineStringType;
|
||||
else if (typeString == QLatin1String("str"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user