PDA

View Full Version : Formatting Excel File



bismitapadhy
27th May 2009, 07:01
I have one excel sheet with data filled.I want to open the file.After Opening the file i want to change the color and format the text of column header.

I am able to open a file using QFile::Open() but, i dont know how to doformatting.Please help ragarding this.Thank You :)

faldzip
27th May 2009, 07:57
XLS are binary files so you have to open them as a binary, but then you can read only raw bytes of that file, because there is no such API in Qt that allows you to manipulate XLS files on some higher level than bytes. So you have to find some library that can do this or you have to know the format of the xls file to understand what bytes you read mean.

P.S. Different thing is with xlsx and docx new formats, because they are just zipped set of xml files, so you can use than for example DOM API in Qt, but you still have to know what that tags, attributes and values mean - you have to know the file format, structure.

dingetje
27th May 2009, 11:16
Excel works quite well with HTML formatted files. If you generate an HTML table with colored cells and write it to a file with .xls extension (even when in reality its a text based HTML file), Excel will detect this and render the resulting table quite nicely.

Of course this only works with rather simple tables, I don't know if you can have formula's and such.