You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following line in Worksheet::writeDate() is causing a bottleneck when writing fairly large numbers of QDates to a worksheet:
double value = datetimeToNumber(QDateTime(dt, QTime(0,0,0)), d->workbook->isDate1904());
The solution is to exclude QDateTime from the calculation when dealing with QDates. So the above line in Worksheet::writeDate() would be replaced with this:
double value = dateToNumber(dt);
The new dateToNumber() function in xlsxutility.cpp would be as follows:
qint64 dateToNumber(const QDate &dt) const
{
const QDate epoch(1899, 12, 31);
const QDate excel_date(epoch.daysTo(dt));
// Account for Excel erroneously treating 1900 as a leap year
if (excel_date > 59) // 59 = 28-Feb-1900
return excel_date + 1;
else
return excel_date;
}
I'm not 100% clear on the Workbook::isDate1904() function, but the above approach works in my own extension of QXlsx. Outputting ~250,000 cells containing QDates now takes about 12 seconds instead of around 5-10 minutes.
The text was updated successfully, but these errors were encountered:
The following line in Worksheet::writeDate() is causing a bottleneck when writing fairly large numbers of QDates to a worksheet:
double value = datetimeToNumber(QDateTime(dt, QTime(0,0,0)), d->workbook->isDate1904());
The solution is to exclude QDateTime from the calculation when dealing with QDates. So the above line in Worksheet::writeDate() would be replaced with this:
double value = dateToNumber(dt);
The new dateToNumber() function in xlsxutility.cpp would be as follows:
I'm not 100% clear on the Workbook::isDate1904() function, but the above approach works in my own extension of QXlsx. Outputting ~250,000 cells containing QDates now takes about 12 seconds instead of around 5-10 minutes.
The text was updated successfully, but these errors were encountered: