From 3b83f5662926303fc6f9e0aa59c06dbf7acd8e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B7=E9=A6=97?= <34974211+YuanDad@users.noreply.github.com> Date: Thu, 25 Aug 2022 10:36:32 +0800 Subject: [PATCH 1/2] Update xlsxstyles.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新建的Excel文件,每个格子会自动创建一个(垂直居中),但此时并没有添加applyAlignment属性,这将造成读取时丢失默认的垂直居中样式,并且此问题无法在读取动作后得到有效的解决,所以建议此处不管有没有applyAlignment属性,都应该尝试去读取,而且因为QXmlStreamReader::readNextStartElement函数的特性,此处的尝试读取并不会对原功能造成任何影响 --- QXlsx/source/xlsxstyles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QXlsx/source/xlsxstyles.cpp b/QXlsx/source/xlsxstyles.cpp index d265d19e..d9bd451e 100644 --- a/QXlsx/source/xlsxstyles.cpp +++ b/QXlsx/source/xlsxstyles.cpp @@ -1198,7 +1198,7 @@ bool Styles::readCellXfs(QXmlStreamReader &reader) } } - const auto apply = parseXsdBoolean(xfAttrs.value(QLatin1String("applyAlignment")).toString()); + const auto apply = parseXsdBoolean(xfAttrs.value(QLatin1String("applyAlignment")).toString(), true); if(apply) { reader.readNextStartElement(); if (reader.name() == QLatin1String("alignment")) { From 3532627fdbee001bf0d4562afe514da4b8759e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B7=E9=A6=97?= <34974211+YuanDad@users.noreply.github.com> Date: Thu, 25 Aug 2022 10:40:10 +0800 Subject: [PATCH 2/2] Update xlsxworksheet.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QXlsx增加了对打印页边距的支持,但是却没有在复制sheet的时候将打印页边距属性一并复制,这违背了复制的含义,建议修改 --- QXlsx/source/xlsxworksheet.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/QXlsx/source/xlsxworksheet.cpp b/QXlsx/source/xlsxworksheet.cpp index 565d6755..d9bc7009 100644 --- a/QXlsx/source/xlsxworksheet.cpp +++ b/QXlsx/source/xlsxworksheet.cpp @@ -219,6 +219,23 @@ Worksheet *Worksheet::copy(const QString &distName, int distId) const // sheet_d->dataValidationsList = d->dataValidationsList; // sheet_d->conditionalFormattingList = d->conditionalFormattingList; + sheet_d->PpaperSize = d->PpaperSize; + sheet_d->Pscale = d->Pscale; + sheet_d->PfirstPageNumber = d->PfirstPageNumber; + sheet_d->Porientation = d->Porientation; + sheet_d->PuseFirstPageNumber = d->PuseFirstPageNumber; + sheet_d->PhorizontalDpi = d->PhorizontalDpi; + sheet_d->PverticalDpi = d->PverticalDpi; + sheet_d->Prid = d->Prid; + sheet_d->Pcopies = d->Pcopies; + sheet_d->PMfooter = d->PMfooter; + sheet_d->PMheader = d->PMheader; + sheet_d->PMbotton = d->PMbotton; + sheet_d->PMtop = d->PMtop; + sheet_d->PMright = d->PMright; + sheet_d->PMleft = d->PMleft; + sheet_d->ModdHeader = d->ModdHeader; + return sheet; }