Reading .XLS file

BlitzMax Forums/BlitzMax Programming/Reading .XLS file

degac(Posted 2009) [#1]
A quick question: anyone knows how to read an .xls (MS Excel) file?
I found on [a http://www.wotsit.org/list.asp?search=xls&button=GO!] wotsit these references[ /a], but from what I understand .xls format is a little complicated to read...

Another solution I found is to consider the .xls file as a database and read it via sqlite/database engine.

I need only the 'values' of the table.

What solutions can you suggest? Thanks


Muttley(Posted 2009) [#2]
Do you need to automate it, or just a one-off.

For a one-off it's probably easiest to export it as CSV format.


FlameDuck(Posted 2009) [#3]
Another solution I found is to consider the .xls file as a database and read it via sqlite/database engine.
I'm pretty sure that accessing Excel through ODBC doesn't work under newer versions of Windows, and in either case would require you to have Microsoft Office installed.

The solutions I'd recommend are:
1) Compile MyXls as a .Net assembly and use that from BltizMAX (I'm pretty sure Lee Page figured out how to interface with .Net assemblies).
2) Use Apache POI and something like JCC to produce a Python friendly C++ interface, which should be trivial to use with BlitzMAX.

In either case you've pretty much got your work cut out for you. Excel files are horrible to work with even under the best (ie. Microsoft only) conditions.


Digital Anime(Posted 2009) [#4]

Do you need to automate it, or just a one-off.

For a one-off it's probably easiest to export it as CSV format.



Agree with Muttley on this, you just need to use ReadLine to read an entire row and check for the string wich seperates the columns.


degac(Posted 2009) [#5]

For a one-off it's probably easiest to export it as CSV format


Unfortunately it's something I need to do quite often. At the moment I save the file in CSV format, and the Bmax program read & elaborate this.
I was thinking to make things a little 'quicker'...but at this point I will remain with my 'manually' solution.

Thanks again for the answers.


Digital Anime(Posted 2009) [#6]
To automate things you could use a commandline tool like xls2csv.exe and implement that somewhere. It could save you lot's of time, why reinvent the wheel again?

I'm not sure if Bmax can run commandline tools with extra flags, but maybe creating a batch file with the executable and all needed flags and running that one could do the trick.


xlsior(Posted 2009) [#7]
Just thinking the same, scripting a command-line xls 2 csv program.

Of course, to complicate matters tremendously you probably should account for .xlsx file formats as well (Office 2007 / 2010) which are VERY differeny from the older .xls files since you're bound to have to deal with those sooner or later.
(.xlsx is essentially a zipped up proprietary XML file)


degac(Posted 2009) [#8]
xls2csv.exe????


Thanks for the hint!
I'll investigate in this direction!


degac(Posted 2009) [#9]
Thanks very much to Digital Anime!

I've implemented successfully in my program xls2csv (running via a process) and it works like a charm!