Add QDateTime support for QXlsx::Cell
This commit is contained in:
@@ -20,6 +20,7 @@ private Q_SLOTS:
|
||||
void testReadWriteBool();
|
||||
void testReadWriteBlank();
|
||||
void testReadWriteFormula();
|
||||
void testReadWriteDateTime();
|
||||
};
|
||||
|
||||
DocumentTest::DocumentTest()
|
||||
@@ -156,6 +157,46 @@ void DocumentTest::testReadWriteFormula()
|
||||
QFile::remove("test.xlsx");
|
||||
}
|
||||
|
||||
void DocumentTest::testReadWriteDateTime()
|
||||
{
|
||||
Document xlsx1;
|
||||
QDateTime dt(QDate(2012, 11, 12), QTime(6, 0), Qt::UTC);
|
||||
|
||||
xlsx1.write("A1", dt);
|
||||
|
||||
Format *format = xlsx1.createFormat();
|
||||
format->setFontColor(Qt::blue);
|
||||
format->setBorderStyle(Format::BorderDashDotDot);
|
||||
format->setFillPattern(Format::PatternSolid);
|
||||
xlsx1.write("A2", dt, format);
|
||||
|
||||
Format *format3 = xlsx1.createFormat();
|
||||
format3->setNumberFormat("dd/mm/yyyy");
|
||||
xlsx1.write("A3", dt, format3);
|
||||
|
||||
xlsx1.saveAs("test.xlsx");
|
||||
|
||||
Document xlsx2("test.xlsx");
|
||||
|
||||
QCOMPARE(xlsx2.cellAt("A1")->dataType(), Cell::Numeric);
|
||||
QCOMPARE(xlsx2.cellAt("A1")->isDateTime(), true);
|
||||
QCOMPARE(xlsx2.cellAt("A1")->dateTime(), dt);
|
||||
|
||||
QCOMPARE(xlsx2.cellAt("A2")->dataType(), Cell::Numeric);
|
||||
// QCOMPARE(xlsx2.cellAt("A2")->isDateTime(), true);
|
||||
// QCOMPARE(xlsx2.cellAt("A2")->dateTime(), dt);
|
||||
|
||||
// QCOMPARE(xlsx2.cellAt("A3")->dataType(), Cell::Numeric);
|
||||
// QVERIFY(xlsx2.cellAt("A3")->format()!=0);
|
||||
// qDebug()<<xlsx2.cellAt("A3")->format()->numberFormat();
|
||||
// QCOMPARE(xlsx2.cellAt("A3")->isDateTime(), true);
|
||||
// QCOMPARE(xlsx2.cellAt("A3")->dateTime(), dt);
|
||||
// QCOMPARE(xlsx2.cellAt("A3")->format()->numberFormat(), QString("dd/mm/yyyy"));
|
||||
|
||||
QFile::remove("test.xlsx");
|
||||
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(DocumentTest)
|
||||
|
||||
#include "tst_documenttest.moc"
|
||||
|
||||
Reference in New Issue
Block a user