Game Development Community

Reading and writing to a spreadsheet

by Dave D · in Torque Game Engine · 02/08/2006 (4:46 pm) · 7 replies

I have figured out how to read and write to a text file, piece of cake. No I am wondering how I can read or write to a speadsheet. Anyone done this or know how can show me the way?

#1
02/10/2006 (2:50 am)
It depends on which platform you are targetting (and hence which spreadsheet format you choose). If you want cross-platform, then go for the opensource Openoffice.org spreadsheet format. Their api is exposed to c++ and there is a some documentation and a lot of help on their forums. (This would be my recommendation, BTW).

If you mean Excel you're talking the unwieldy MS Excel object library. You can include it in a C++ class and use the api quite easily to do simple stuff. This approach should work on Windows and maybe Mac (if you include the MAC Excel libraries), but will exclude Linux.
#2
02/10/2006 (6:01 am)
Just after I posted this, a friend of mine suggested the Open Office, it must be cross platform. Thanks for the info.
#3
02/10/2006 (7:56 am)
Greetings!

Couldn't you just do a tab delimited file that could be imported into any spreadsheet or database program? And to go the other way, just export to a tab delimited file from your application.

The allows you to work on the file with stock Torque script functions, such as getField().

- LightWave Dave
#4
02/10/2006 (11:53 am)
Yes, I would go with Fulcrum's advise. Unless I had a very specific reason to use a spreadsheet object. Maybe if I was updating a complex spreadsheet, i.e. replacing only certain data or needed to modify inherent spreadsheet objects like formulas and such. (And even then a spreadsheet based macro manipulating a delimited input file is probably a better way to do it).
So I'd try real hard to find a way around it. Remember you have to deploy the objects you use along with the app/game, to each OS, over whatever version the user may or may not have installed.
#5
02/10/2006 (12:09 pm)
My idea was, to better organize responses for an OFFLINE RPG, but the more I think about you guys are right. I am overly complexing the problem.
#6
02/11/2006 (6:00 am)
I agree with the tab delimited stuff. I haven't had the need to write stuff from Torque, but we are use it to feed data into our games.

We are even using spreadsheets for defining datablocks and audioprofiles, to get data more separated from code in our scripts.
#7
02/11/2006 (6:19 am)
I am using the RPGDialog and am trying to find a better way of storing the responses. The tab delimited file does sound like it will do what I want. I did make a preliminary test using them and it wokred the way I thought. Now just to polish it up

Thanks for the help and info.