I am using Qt 4.5 and Windows XP. I need to create an Microsoft Excel Document that has data (some labels and values) from the Qt application. I need to format those data with some fonts,bold,italics,color, background color etc., Besides ordinary data, there will be Picture files (JPG) also. I need to add those into the Excel. I know retrieving values from Excel using QAxWidget
, QAxObject
. But I don't have a clue about the formatting options that can be applied to cells through Qt and adding images as well?? Any help regarding this are welcome.
To use ODBC for Excel on Windows, the MS Access Database Engine must be downloaded as mentioned in the wiki Note from which this sample code was tested (Win7/ qt4. 9 , Win10/ qt 5.7) , then the connection can work. alternatively in the same Qt wiki Content, you can find different ways of opening MS Excel with Qt.
It can be done using Active Qt. This allows to use Active X (OLE) to interact with Excel. But this requires to have Excel installed on the computer that will run your program. Another solution, if you only need to fill the cells of a spreadsheet is to create a CSV file.
If you simply want to fill a few cells the easiest way is to write a CSV file. If you want more control on the format or layout of your sheets you can use the Excel 2003 XML format. Just create a template of the file as you like, and use it to create your own: it is plain XML, relatively simple to understand.
There are a few options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With