From 9563a0463e0ab6f8a6e9d3cbc3a4a14505541977 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Tue, 18 Nov 2014 09:35:21 +0800 Subject: [PATCH] Issue #64: Don't given count mismatch warning when the attribute doesn't exist. --- src/xlsx/xlsxsharedstrings.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xlsx/xlsxsharedstrings.cpp b/src/xlsx/xlsxsharedstrings.cpp index a03305b..129d0a1 100755 --- a/src/xlsx/xlsxsharedstrings.cpp +++ b/src/xlsx/xlsxsharedstrings.cpp @@ -370,19 +370,21 @@ bool SharedStrings::loadFromXmlFile(QIODevice *device) { QXmlStreamReader reader(device); int count = 0; + bool hasUniqueCountAttr=true; while (!reader.atEnd()) { QXmlStreamReader::TokenType token = reader.readNext(); if (token == QXmlStreamReader::StartElement) { if (reader.name() == QLatin1String("sst")) { QXmlStreamAttributes attributes = reader.attributes(); - count = attributes.value(QLatin1String("uniqueCount")).toString().toInt(); + if ((hasUniqueCountAttr = attributes.hasAttribute(QLatin1String("uniqueCount")))) + count = attributes.value(QLatin1String("uniqueCount")).toString().toInt(); } else if (reader.name() == QLatin1String("si")) { readString(reader); } } } - if (m_stringList.size() != count) { + if (hasUniqueCountAttr && m_stringList.size() != count) { qDebug("Error: Shared string count"); return false; }