mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-30 05:02:52 +08:00
Merge pull request #311 from alexagr/fix-empty-columns
- fix parsing of worksheets that lack column number / have invalid dimension
This commit is contained in:
commit
0c8a17626f
@ -2261,6 +2261,9 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
|
||||
Q_ASSERT(reader.name() == QLatin1String("sheetData"));
|
||||
|
||||
int row_num = 0;
|
||||
int col_num = 0;
|
||||
|
||||
while (!reader.atEnd() && !(reader.name() == QLatin1String("sheetData") &&
|
||||
reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||
if (reader.readNextStartElement()) {
|
||||
@ -2305,6 +2308,12 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
}
|
||||
}
|
||||
|
||||
if (attributes.hasAttribute(QLatin1String("r")))
|
||||
row_num = attributes.value(QLatin1String("r")).toInt();
|
||||
else
|
||||
++row_num;
|
||||
col_num = 0;
|
||||
|
||||
} else if (reader.name() == QLatin1String("c")) // Cell
|
||||
{
|
||||
|
||||
@ -2312,6 +2321,11 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
QString r = attributes.value(QLatin1String("r")).toString();
|
||||
CellReference pos(r);
|
||||
if (r.isEmpty())
|
||||
{
|
||||
pos.setRow(row_num);
|
||||
pos.setColumn(++col_num);
|
||||
}
|
||||
|
||||
// get format
|
||||
Format format;
|
||||
@ -2433,6 +2447,12 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dimension.lastRow() < row_num)
|
||||
dimension.setLastRow(row_num);
|
||||
|
||||
if (dimension.lastColumn() < col_num)
|
||||
dimension.setLastColumn(col_num);
|
||||
}
|
||||
|
||||
void WorksheetPrivate::loadXmlColumnsInfo(QXmlStreamReader &reader)
|
||||
|
Loading…
x
Reference in New Issue
Block a user