# HG changeset patch # User Andre Heinecke # Date 1460726647 -7200 # Node ID 41cd27a643652d2d82d28ba9193b02742c6ae31f # Parent bec3ba3fcbc308df2fe84ebe42c6285c15f94000 Write empty columns for XSLX to avoid strange 0 formatting Excel shows a pretty large bar for zero values diff -r bec3ba3fcbc3 -r 41cd27a64365 src/converter.cpp --- a/src/converter.cpp Mon Apr 11 14:59:25 2016 +0200 +++ b/src/converter.cpp Fri Apr 15 15:24:07 2016 +0200 @@ -230,8 +230,9 @@ if (!ok) { mErrors << "Unparsable number in string: " + choiceMatch.captured(); } - makeBar(html, percent, col2Width, doc, mFmt == Format_PDF); - xlsx.write(row, 2, percent); + makeBar(html, percent, doc); + xlsx.write(row, 2, percent == 0 ? QVariant() : percent); + const QString numStr = choiceMatch.captured("num"); const QString numVotesString = QString("%1% | %2 Number of votes"). arg(choiceMatch.captured(3)).arg(choiceMatch.captured(2)); html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped()); @@ -243,6 +244,36 @@ row++; lastChoiceRow++; } + choiceMatch = choiceAltEx.match(input, cursor); + bool additionalFound = false; + while (choiceMatch.hasMatch() && choiceMatch.capturedStart() <= cursor + 1) { + additionalFound = true; + const QString choice = choiceMatch.captured(1); + cursor = choiceMatch.capturedEnd(); + /* Alternative answer that is just a list of strings */ + qDebug() << choiceAltEx.captureCount(); + qDebug() << choiceMatch.captured(2); + qDebug() << choiceMatch.capturedTexts(); + qDebug() << "Caputured unfilled choice: " << choice; + html << mChoiceTextStyle.arg(choice.toHtmlEscaped()); + makeBar(html, 0, doc); + xlsx.write(row, 2, QVariant()); + const QString numVotesString = QStringLiteral("Keine eingegangenen Antworten"); + html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped()); + xlsx.write(row, 3, numVotesString, mChoiceVotesFmt); + xlsx.setRowHeight(row, CHOICE_ROW_HEIGHT); + row++; + lastChoiceRow++; + choiceMatch = choiceAltEx.match(input, cursor); + QRegularExpressionMatch realMatch = choiceEx.match(input, cursor); + if (choiceMatch.hasMatch() && choiceMatch.capturedStart() == realMatch.capturedStart()) { + /* We have a real match so back to the other pattern. */ + break; + } + } + if (additionalFound) { + goto repeat; + } bars.addRange(QString("B%1:B%2").arg(firstChoiceRow).arg(lastChoiceRow)); // xlsx.groupRows(firstChoiceRow - 2, lastChoiceRow - 1, false); } else if (answerLine == QStringLiteral(TEXT_IDENTIFIER)) {