1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-02-06 05:08:22 +08:00
This commit is contained in:
Look Skyworker 2017-10-08 21:33:00 +09:00
parent 673e025ff7
commit a0907fce31
2 changed files with 30 additions and 23 deletions

View File

@ -37,14 +37,15 @@ int readMSExcel201x();
int readStyle() int readStyle()
{ {
readGoogleSpreadsheet(); int ret = readGoogleSpreadsheet();
return 0; return 0;
} }
int readGoogleSpreadsheet() int readGoogleSpreadsheet()
{ {
Document xlsx("google-spreadsheet.xlsx"); // google docs Document xlsx("google-spreadsheet.xlsx"); // google docs
// Document xlsx("date-time.xlsx"); // ms office online
if (!xlsx.isLoadPackage()) if (!xlsx.isLoadPackage())
{ {
@ -56,11 +57,11 @@ int readGoogleSpreadsheet()
{ {
if (Cell* cell = xlsx.cellAt(row, 1)) if (Cell* cell = xlsx.cellAt(row, 1))
{ {
if (cell == NULL) if ( cell == NULL )
continue; continue;
QVariant var = cell->readValue(); QVariant var = cell->readValue();
qint32 styleNo = cell->styleNumber(); qint32 styleNo = cell->styleNumber();
if (styleNo >= 0) if ( styleNo >= 0 )
{ {
qDebug() << row << " " << var << " , style:" << styleNo; qDebug() << row << " " << var << " , style:" << styleNo;
} }
@ -71,7 +72,7 @@ int readGoogleSpreadsheet()
} }
} }
/* debug output /* Deug output
1 QVariant(double, 1) , style: 1 1 QVariant(double, 1) , style: 1
2 QVariant(QString, "2") , style: 2 2 QVariant(QString, "2") , style: 2
3 QVariant(double, 3) , style: 3 3 QVariant(double, 3) , style: 3
@ -82,13 +83,12 @@ int readGoogleSpreadsheet()
8 QVariant(double, 8) , style: 8 8 QVariant(double, 8) , style: 8
9 QVariant(double, 9) , style: 9 9 QVariant(double, 9) , style: 9
10 QVariant(QString, "1900. 1. 9") , style: 10 10 QVariant(QString, "1900. 1. 9") , style: 10
11 QVariant(QDateTime, QDateTime(1900-01-11 00:00:00.000 KST Qt::TimeSpec(LocalTime))) , style: 11 11 QVariant(QTime, QTime("00:00:00.000")) , style: 11
12 QVariant(QString, "1900. 1. 11 AM 12:00:00") , style: 12 12 QVariant(QString, "1900. 1. 11 AM 12:00:00") , style: 12
13 QVariant(QDateTime, QDateTime(1900-01-13 00:00:00.000 KST Qt::TimeSpec(LocalTime))) , style: 13 13 QVariant(QDateTime, QDateTime(1900-01-13 00:00:00.000 KST Qt::TimeSpec(LocalTime))) , style: 13
*/ */
/* /* Testing fo read google spreadsheet file (made by google docs)
testing fo read google spreadsheet file (made by google docs)
https://github.com/j2doll/QXlsx/blob/master/image/LibreOffice-Google-XLSX.png https://github.com/j2doll/QXlsx/blob/master/image/LibreOffice-Google-XLSX.png
1 QVariant(double, 1) OK:it's auto style (1) 1 QVariant(double, 1) OK:it's auto style (1)
@ -118,6 +118,8 @@ int readLibreOffice()
int readMSExcel201x() int readMSExcel201x()
{ {
// Document xlsx("date-time.xlsx"); // ms office online
return 0; return 0;
} }

View File

@ -124,35 +124,40 @@ QVariant Cell::readValue() const
{ {
Q_D(const Cell); Q_D(const Cell);
QVariant ret; QVariant ret; // return value
ret = d->value; ret = d->value;
if (isDateTime()) if (isDateTime())
{ {
QDateTime dt = dateTime(); QDateTime dt = dateTime();
ret = dt; ret = dt;
return ret;
/* qint32 styleNo = d->styleNumber;
double val = d->value.toDouble();
if (val < 1) if (styleNo == 10)
{ {
ret = dt.time(); // it's time type
return ret;
} }
double dFmod = fmod(val, double(1.0)); if (styleNo == 11) // only time
double dRValue = 1.0 / (1000 * 60 * 60 * 24);
if ( dFmod < dRValue )
{ {
ret = dt.date(); // it's date type QTime timeValue = dt.time();
ret = timeValue;
return ret; return ret;
} }
ret = dt; if (styleNo == 12)
return ret; {
*/
} }
if (styleNo == 13)
{
}
return ret;
}
if (hasFormula()) if (hasFormula())
{ {