1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-01-16 04:42:53 +08:00

Merge pull request #341 from hxbb00/master

fix: workbook.xml.rels with absolute path
This commit is contained in:
Jay Two 2024-08-08 17:21:20 +09:00 committed by GitHub
commit 9c704961d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -607,15 +607,21 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
AbstractSheet *sheet = addSheet(name, sheetId, type);
sheet->setSheetState(state);
QString strFilePath = filePath();
if (relationship.target.startsWith("/")) {
QString fullPath = QDir::cleanPath(relationship.target.mid(1));
// const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() +
// QLatin1String("/") + relationship.target);
const auto parts = splitPath(strFilePath);
QString fullPath =
QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
sheet->setFilePath(fullPath);
sheet->setFilePath(fullPath);
}else{
QString strFilePath = filePath();
// const QString fullPath = QDir::cleanPath(splitPath(strFilePath).constFirst() +
// QLatin1String("/") + relationship.target);
const auto parts = splitPath(strFilePath);
QString fullPath =
QDir::cleanPath(parts.first() + QLatin1String("/") + relationship.target);
sheet->setFilePath(fullPath);
}
} else if (reader.name() == QLatin1String("workbookPr")) {
QXmlStreamAttributes attrs = reader.attributes();
if (attrs.hasAttribute(QLatin1String("date1904")))