QtExcel / QXlsx

Excel file(*.xlsx) reader/writer library using Qt 5 or 6. Descendant of QtXlsxWriter.
https://qtexcel.github.io/QXlsx/
MIT License
1.13k stars 352 forks source link

opening doc erases chart style data #177

Open zzmiyy opened 3 years ago

zzmiyy commented 3 years ago

Hello! I have trouble with writing docs. Im using template document with multiple sheets and some charts, for example its "point with smooth curves" and some style settings . Im copy template with QFile, opening, filling data into one sheet and save doc. After open i can see, that my chart now is "point with straight lines and markers", and all style settings erased. It is a bug or i do smth wrong?

j2doll commented 3 years ago

Can you please post some publicly available example code? I think I or others can help you.

Please pull request to repo. https://github.com/JayTwoLab/qxlsx-issues-177

zzmiyy commented 3 years ago

Can you please post some publicly available example code? I think I or others can help you.

Hello, here's examples:

     if(!QFile::copy(QDir::currentPath() + QDir::separator() + "before.xlsx",
                    QDir::currentPath() + QDir::separator() +"after.xlsx"))
    {
        QFile::remove(QDir::currentPath() + QDir::separator() +"after.xlsx");
        QFile::copy(QDir::currentPath() + QDir::separator() + "before.xlsx",
                    QDir::currentPath() + QDir::separator() +"after.xlsx");
    }
    {       //example 1
        QXlsx::Document doc(QDir::currentPath() + QDir::separator() +"after.xlsx");
        doc.load();
        doc.write(1,1, "HELLO EXCEL WORLD");
        doc.save();
    }
    {       //example 2
        QXlsx::Document doc(QDir::currentPath() + QDir::separator() +"before.xlsx");
        doc.load();
        doc.write(1,1, "HELLO EXCEL WORLD");
        doc.saveAs(QDir::currentPath() + QDir::separator() +"after2.xlsx");
    }

before.xlsx after.xlsx after2.xlsx

j2doll commented 3 years ago

I applied the example code to: https://github.com/JayTwoLab/qxlsx-issues-177

It seems that the chart properties part should be checked.