PDA

View Full Version : .xls files



sedi
13th November 2012, 02:04
Hi,
I want to be able to read/write simple excel spreadsheets (don't we all?) using QtCreator for Windows.

I've tried to use xlslib, but using a Windows system I have problems getting this to work (see this sourceforge (https://sourceforge.net/projects/xlslib/forums/forum/402380/topic/6165364)thread).

What I actually need is just write numbers/strings to cells. Formatting, formulas, different sheets etc. would be nice-to-have, but absolutely not necessary.I can't take the ActiveX approach because I need a multi-platform solution - I am building the program for Windows and for Android (more to come later).

Has anyone managed to integrate xlslib into Qt under Windows?
Is there a simpler alternative?

As this post intends to aim for the Qt side of my problem, please forgive my cross posting (see link above) concerning my efforts to specifically deal with the xlslib side of it.

Any help/hint/link is gratefully appreciated!

sedi
14th November 2012, 01:20
Hi,
by now I think I have managed to build xlslib. I'll list the necessary steps cleanly in this thread as soon as I know this leads to success.
After running make I've encountered some nice xls sheets from test programs. Yesss.

My question: I've managed that by compiling the package via Cygwin from a command line - how do I get the result of that integrated into a Qt project in the Creator?

Or, specifically:

What am I looking for? A .dll? A .lib? (nothing there)
Do I need all the .o-Files somewhere?
Do I have to include the makefile in my toolchain (whatever the latter actually means)?
How do I refer to it in the Creator? Via #include?

You see - I'm a n00b looking for some very basic advice here :-\

I've uploaded the folder with the compiled xlslib here (http://www.classintouch.de/xlslib_compiled.zip) (file was too big to attach it to the post).

I am sure, Excel support is what *many* programmers want to have and imho there's not much information out there for beginners like me. It would be so nice if we could change that here and if this thread resulted in a how-to!

ChrisW67
14th November 2012, 20:50
If you have built xsllib under Cygwin then it is unlikely there will be a straightforward way to integrate this library with a program built outside Cygwin.

As far as I can tell xlslib comes with project files for MSVC 2005 and 2008 and has reports of successful builds with MingW. You should build xlslib with a the same compiler as your Qt libraries and project, then linking against it becomes trivial.

sedi
15th November 2012, 18:53
Thank you for the answer!

If I understand you correctly, I want to

Understand Qt project file syntax and logic
Understand the MSVC .vcproj file
"Translate" the .vcproj into a .pro file
-> Either include this into my project and compile/build xlslib together with my stuff.
-> or compile it to a .dll or .lib or something else (what?) and link my project against it.


Is that correct?
Is it right that the .pro file actually "tells" qmake what to do?
Is option 4 better than 5 when I want this to run multi-platform? By now I have my project running with Win & Android, others shall follow.

I'm only starting to hopefully understand this cosmos, sorry.

The Cygwin compiling needed the use of a "bootstrap" and a "configure" script that apparently generated a "makefile" script which, I think, did the actual compiling. Is it right that a correct .vcproj or .pro file would (have to) care of all the things those scripts do? I mean: can I assume that I don't need to dig deeper into the shell scripts? Being a Linux n00b, they tend to look like the results of a well-oiled armadillo rolling itself over a computer keyboard, in my eyes at least. It would be quite encouraging to be able to toss them aside and "just" learn to work the project files ;-)

I've found
http://doc.qt.digia.com/stable/qmake-project-files.html
and
http://doc.qt.digia.com/qt/qmake-variable-reference.html
as possible starting points for the Qt side,

and this
http://www.asp.net/web-forms/tutorials/deployment/web-deployment-in-the-enterprise/understanding-the-project-file
seems to be interesting for the MS side.

Do these pages look reasonable as starting points for this case? Would you recommend better resources?

Sorry for these many questions, I just genuinely want to understand this.

sedi
17th November 2012, 15:05
I am still not sure, if I understand the answer correctly. I'd really appreciate advice about if what I tried to derive from it is the right way to go or if I got it wrong.

amleto
17th November 2012, 16:52
if you want to use xlslib with qt, then the .libs need to be compiled with same compiler. You compiled xlslib under cygwin - did you ALSO compile Qt under cygwin?

sedi
17th November 2012, 17:09
Thank you amleto! This I have indeed understood - I can obviously not use what I have compiled with gcc under cygwin. There were no .lib, .dll or .so files anyway - which I thought to be odd. But this whole approach is futile in the first place, like you've said.

So right now (maybe I should have stated that clearer, sorry!) I am trying to compile the xlslib source code in Qt - which uses the mingw compiler.

Does that sound more reasonable with the ideas of post #4 in this thread?

amleto
17th November 2012, 18:44
to be pedantic, you cant compile xlslib with Qt since Qt doesn't have a c++ compiler. But, yes, compiling xlslib with mingw c++ compiler (you'll need a makefile?) is reasonable considering your Qt libs were also built with mingw.