• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Reading from XLS

WildW

Senior member
Hi folks,

Does anyone know of a free and ready-made way of reading an MS Excel .xls file? I've looked at Microsoft's terrifying 350 page specification of the xls file format and concluded that writing one from scratch is non-trivial. Ideally there would be a library I can pull into my existing C++ program.

So far a quick Google has revealed the existance of a paid-for library to do just this, but free is better. I figure if OpenOffice can open an xls file then there may well be something open-source.

Alternatively, is there maybe some kind of shortcut using something VB-Scripty that would open an xls file and convert it to plain text values so long as Excel/Office is installed?
 
If you could use an .XLSX file from Office 2007 or 2010, then those files are just zip files full of xml files. Which should be much easier to parse than whatever ungodly thing is inside of the old .XLS file format.
 
What are you trying to do with the file? What kind of environment, does the computer have Excel installed? You can open a file using Excel itself and then control Excel from another program.
 
Unfortunately I have to open the output file from some other program, which is not Excel but does output XLS format. . . don't ask. I need to extract one of the sheets within it to get the columns of numbers therein.

I'll take a look at libole2, and I've found something promising at http://www.falcoware.com/ that looks to be a free library to do the job.
 
If you just need to read the data in the XLSs, I think you can use the Microsoft Jet Engine with an Excel provider (IIRC, there is a standalone provider). The is some caveats with this method (for example : only the first 8 lines are used to determine if the string columns are varchar(255) or text, so you have to be extra careful for these cases.)
 
I had a play with a XLS loading library today but it died when shown a complex file. I've used a Visual Basic script in the end to convert the XLS to csv by dragging and dropping the file onto it - it will make things a two step process, but it will work.
 
Pretty easy in perl with Spreadsheet:😛arseExcel to get the values of (a) specific column(s).

You can then turn around and use Spreadsheet::WriteExcel then you can just open it directly in Excel. Even easier would be to just write it to a CSV format and import that into Excel.
 
Back
Top