Skip to content

Commit

Permalink
fix: workbook.xml.rels with absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
hxbb00 authored Jul 29, 2024
1 parent db36c65 commit 3192b80
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions QXlsx/source/xlsxworkbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,21 @@ bool Workbook::loadFromXmlFile(QIODevice *device)

AbstractSheet *sheet = addSheet(name, sheetId, type);
sheet->setSheetState(state);
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);
if (relationship.target.startsWith("/")) {
QString fullPath = QDir::cleanPath(relationship.target.mid(1));

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")))
Expand Down

0 comments on commit 3192b80

Please sign in to comment.