comparison src/converter.cpp @ 39:41cd27a64365

Write empty columns for XSLX to avoid strange 0 formatting Excel shows a pretty large bar for zero values
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 15 Apr 2016 15:24:07 +0200
parents ca66763b6524
children f6c53e896008
comparison
equal deleted inserted replaced
36:bec3ba3fcbc3 39:41cd27a64365
228 bool ok; 228 bool ok;
229 double percent = choiceMatch.captured(3).toDouble(&ok); 229 double percent = choiceMatch.captured(3).toDouble(&ok);
230 if (!ok) { 230 if (!ok) {
231 mErrors << "Unparsable number in string: " + choiceMatch.captured(); 231 mErrors << "Unparsable number in string: " + choiceMatch.captured();
232 } 232 }
233 makeBar(html, percent, col2Width, doc, mFmt == Format_PDF); 233 makeBar(html, percent, doc);
234 xlsx.write(row, 2, percent); 234 xlsx.write(row, 2, percent == 0 ? QVariant() : percent);
235 const QString numStr = choiceMatch.captured("num");
235 const QString numVotesString = QString("%1% | %2 Number of votes"). 236 const QString numVotesString = QString("%1% | %2 Number of votes").
236 arg(choiceMatch.captured(3)).arg(choiceMatch.captured(2)); 237 arg(choiceMatch.captured(3)).arg(choiceMatch.captured(2));
237 html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped()); 238 html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped());
238 xlsx.write(row, 3, numVotesString, mChoiceVotesFmt); 239 xlsx.write(row, 3, numVotesString, mChoiceVotesFmt);
239 xlsx.setRowHeight(row, CHOICE_ROW_HEIGHT); 240 xlsx.setRowHeight(row, CHOICE_ROW_HEIGHT);
240 /* As long as we can match a choice which is either before the next question 241 /* As long as we can match a choice which is either before the next question
241 or before the end of the document */ 242 or before the end of the document */
242 choiceMatch = choiceEx.match(input, cursor); 243 choiceMatch = choiceEx.match(input, cursor);
243 row++; 244 row++;
244 lastChoiceRow++; 245 lastChoiceRow++;
246 }
247 choiceMatch = choiceAltEx.match(input, cursor);
248 bool additionalFound = false;
249 while (choiceMatch.hasMatch() && choiceMatch.capturedStart() <= cursor + 1) {
250 additionalFound = true;
251 const QString choice = choiceMatch.captured(1);
252 cursor = choiceMatch.capturedEnd();
253 /* Alternative answer that is just a list of strings */
254 qDebug() << choiceAltEx.captureCount();
255 qDebug() << choiceMatch.captured(2);
256 qDebug() << choiceMatch.capturedTexts();
257 qDebug() << "Caputured unfilled choice: " << choice;
258 html << mChoiceTextStyle.arg(choice.toHtmlEscaped());
259 makeBar(html, 0, doc);
260 xlsx.write(row, 2, QVariant());
261 const QString numVotesString = QStringLiteral("Keine eingegangenen Antworten");
262 html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped());
263 xlsx.write(row, 3, numVotesString, mChoiceVotesFmt);
264 xlsx.setRowHeight(row, CHOICE_ROW_HEIGHT);
265 row++;
266 lastChoiceRow++;
267 choiceMatch = choiceAltEx.match(input, cursor);
268 QRegularExpressionMatch realMatch = choiceEx.match(input, cursor);
269 if (choiceMatch.hasMatch() && choiceMatch.capturedStart() == realMatch.capturedStart()) {
270 /* We have a real match so back to the other pattern. */
271 break;
272 }
273 }
274 if (additionalFound) {
275 goto repeat;
245 } 276 }
246 bars.addRange(QString("B%1:B%2").arg(firstChoiceRow).arg(lastChoiceRow)); 277 bars.addRange(QString("B%1:B%2").arg(firstChoiceRow).arg(lastChoiceRow));
247 // xlsx.groupRows(firstChoiceRow - 2, lastChoiceRow - 1, false); 278 // xlsx.groupRows(firstChoiceRow - 2, lastChoiceRow - 1, false);
248 } else if (answerLine == QStringLiteral(TEXT_IDENTIFIER)) { 279 } else if (answerLine == QStringLiteral(TEXT_IDENTIFIER)) {
249 QRegularExpressionMatch textMatch = freetxtEx.match(input, cursor); 280 QRegularExpressionMatch textMatch = freetxtEx.match(input, cursor);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)