Editing a spreadsheet

  • Hi,

    I want to edit a spreadsheet (Excel file) and keep the presentation (color, invisible cells,..) because i need to print the table after editing it.

    What is the best way to handle this with Qt ? Convert to HTML ? to csv ? to xml ?
    I'm open to any suggestions :)


  • Lifetime Qt Champion

    If you can just select the excel XML format, i would go that route.
    Then just load it as pure xml and change what you need.

    But it depends on what you need to change. if you must do massive changes, xml is annoying as u must add nodes etc the right places.

  • I just need to add few informations (5 or 6 string).
    If i use xml i will keep the excel graphic ?

    Thank you

  • Lifetime Qt Champion

    ok, would be really easy with XML format.

    I did not test in newer versions.
    In 2007 office it did not keep
    You should just test it.

  • Qt Champions 2018

    For xlsx files you can try using QtXlsxWriter. it might loose some of the contents of the file if it's very complex so I'd give it a test run.

  • Hi @VRonin and thanks for the reply,

    I don't know how to install module on Qt, can you explain me how to do it ?

  • Qt Champions 2018

    The homepage, under "Getting started" has quite clear instructions

  • Yep my bad,

    But when i include the .pri file i get compiling error about a QVectorQZipReader::FileInfo in the ZipReader::init function

  • Qt Champions 2018

    @Zoptune The original author is not maintaining the project anymore and his/her version is now broken on Qt 5.6. I'm keeping it working in my fork https://github.com/VSRonin/QtXlsxWriter

  • Perfect ! Thank you very much for your work :)

  • Hi again @VRonin ,

    How, do you think, can i print my xlsx doc after editing ?


  • Qt Champions 2018

    @Zoptune The library has no rendering functionality i.e. has no tool to "paint" the excel document, just to edit its parts. If you have excel installed on the machine that should print the file you can try this solution and use QProcess in your program to launch the WScript.exe

  • @VRonin Yep, this is solution i have seen yesterday, but i don't want to have Excel installed so i use a QProcess that launch LibreOffice to do a convertion in a pdf file and then print the pdf from my app.
    I'm trying to find if it is possible with QtXlsx to change the document orientation (i need it to be in landscape format).


  • Qt Champions 2018

    There is a pull request on the main project that implements the feature. The author did not submit it to my fork so I did not review and merged it yet but feel free to try it

  • @VRonin Sorry but i never used git,

    Can u explain me how to do ?


    EDIT : tried but doesn't work, the output file is corrupted

    EDIT 2 : It's working now :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.