Skip to content

Commit 3192b80

Browse files
authored
fix: workbook.xml.rels with absolute path
#310
1 parent db36c65 commit 3192b80

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

QXlsx/source/xlsxworkbook.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,21 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
607607

608608
AbstractSheet *sheet = addSheet(name, sheetId, type);
609609
sheet->setSheetState(state);
610-
QString strFilePath = filePath();
611-
612-
// const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() +
613-
// QLatin1String("/") + relationship.target);
614-
const auto parts = splitPath(strFilePath);
615-
QString fullPath =
616-
QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
617-
618-
sheet->setFilePath(fullPath);
610+
if (relationship.target.startsWith("/")) {
611+
QString fullPath = QDir::cleanPath(relationship.target.mid(1));
612+
613+
sheet->setFilePath(fullPath);
614+
}else{
615+
QString strFilePath = filePath();
616+
617+
// const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() +
618+
// QLatin1String("/") + relationship.target);
619+
const auto parts = splitPath(strFilePath);
620+
QString fullPath =
621+
QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
622+
623+
sheet->setFilePath(fullPath);
624+
}
619625
} else if (reader.name() == QLatin1String("workbookPr")) {
620626
QXmlStreamAttributes attrs = reader.attributes();
621627
if (attrs.hasAttribute(QLatin1String("date1904")))

0 commit comments

Comments
 (0)