Closed celoewe1971 closed 1 year ago
Dear @celoewe1971
Thanks for the great analysis.
Can you show me some example code?
Hello @j2doll
example code for what ? The current code ist not working correct when you use text.xlsx. So I think the code fragment should be like
... // date/time can only be positive number, // so only the first section of the format make sense. case '#': // this is new an working case ';': return false; ...
This has been reflected. https://github.com/QtExcel/QXlsx/commit/d0f846a31ed45b2c0c25ff829ffe7e8dcfb9c503
Please test it out and post the results.
Works fine. Following test code displays the correct 100 (not a wrong datetime with the 'old' code)
using namespace QXlsx;
Document xlsx("Test.xlsx");
if (xlsx.load())
{
int row = 2; int col = 1;
Cell* cell = xlsx.cellAt(row, col); // get cell pointer.
if ( cell != NULL )
{
QVariant var = cell->readValue();
qDebug() << var; // display value.
}
}
Works fine. Following test code displays the correct 100 (not a wrong datetime with the 'old' code)
using namespace QXlsx; Document xlsx("Test.xlsx"); if (xlsx.load()) { int row = 2; int col = 1; Cell* cell = xlsx.cellAt(row, col); // get cell pointer. if ( cell != NULL ) { QVariant var = cell->readValue(); qDebug() << var; // display value. } }
Thanks for the great help. 👍
Hi,
First of all: Great work 👍
Now to what I have found: In the attached test file, the two cells A2 and A3 are interpreted as DateTime. This is wrong. The values are clearly numbers. The reason is the custom formatting of the cell as you can see in the screenshot (german excel).
NumFormatParser::isDateTime(const QString &formatCode) causes the error. The formatCode is checked for 'd' and 'm' with regard to the date. Shouldn't false be returned if '#' is part of it ?
test.xlsx ,