Closed liufeijin closed 6 years ago
very sad , maybe i must to try other lib.
i want to try Qlibxlsxwriter but fail as the zip.h can't find . and try to set it . fail
Dear liufeijin:
I do not know the cause of the case yet. https://github.com/j2doll/QXlsx/issues/15#issue-371363811
If you wanna use Qlibxlsxwriter, you must install zlib. See how to setup. And if you use MSYS2 or Visual Studio for Qlibxlsxwriter, See tested environments .
If the solution still does not work, try Qxlnt.
Each library does not fully support ECMA 376.
Dear J2doll I found which different will case this bug ////////////////////////////////////////////// I rename the excel file V1805133.XLSX to V1805133.ZIP and extract to V1805133befor after writing by QXlsx (don't open and reapair by office) rename to V1805133.zip and extract to V1805133after.
I replace 1 file from v1805133before folder to v1805133after folder
1 /xl/drawing1.xml
the excel file will be normal .
So the problem is QXls writs the xml file in wrong format or lose some thing . i think this maybe can be fixed . Cloud you have a look ?
the file /xl/drawing1.xml is lose beleow
void DrawingTwoCellAnchor::saveToXml(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("xdr:twoCellAnchor")); writer.writeAttribute(QStringLiteral("editAs"), QStringLiteral("oneCell"));
saveXmlMarker(writer, from, QStringLiteral("xdr:from"));
saveXmlMarker(writer, to, QStringLiteral("xdr:to"));
saveXmlObject(writer);
writer.writeEmptyElement(QStringLiteral("xdr:clientData"));
writer.writeEndElement(); //xdr:twoCellAnchor
} is for writing /xl/drawing1.xml
the saveXmlObject(writer); has problem , it dosn't save any thing
below is lost
-
-
</xdr:nvSpPr>
</xdr:sp>
in xlsxdrawinganchor.cpp void DrawingTwoCellAnchor::saveToXml(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("xdr:twoCellAnchor")); writer.writeAttribute(QStringLiteral("editAs"), QStringLiteral("oneCell"));
saveXmlMarker(writer, from, QStringLiteral("xdr:from"));
saveXmlMarker(writer, to, QStringLiteral("xdr:to"));
saveXmlObject(writer);
writer.writeEmptyElement(QStringLiteral("xdr:clientData"));
writer.writeEndElement(); //xdr:twoCellAnchor
} to be add xdr:nvSpPr ... like as ( but below is xdr:nuPicPr)
writer.writeStartElement(QStringLiteral("xdr:nvPicPr")); writer.writeEmptyElement(QStringLiteral("xdr:cNvPr")); writer.writeAttribute(QStringLiteral("id"), QString::number(m_id)); writer.writeAttribute(QStringLiteral("name"), QStringLiteral("Picture %1").arg(m_id));
writer.writeStartElement(QStringLiteral("xdr:cNvPicPr"));
writer.writeEmptyElement(QStringLiteral("a:picLocks"));
writer.writeAttribute(QStringLiteral("noChangeAspect"), QStringLiteral("1"));
writer.writeEndElement(); //xdr:cNvPicPr
writer.writeEndElement(); //xdr:nvPicPr
i have repaired this error, and updated the code , PLS check
Dear @liufeijin:
I got the warning when i write a excel (PLS refer attachment) as below codes
QXlsx::Document xlsx("d:/V1805133.xlsx"); if (!xlsx.isLoadPackage()) { qDebug() << "Failed to load data.xlsx";
if the excel file include a drawing , after writing as above , the drawing will be lose.