f



Reading an Excel .xls File without using Excel.Application?

Hi all,

My VB6 app needs to be able to read from an Excel .xls file.  However, the 
target computer won't have Excel installed.  All the online examples I've 
found for reading Excel files assume you're doing this...

Dim xl As Excel.Application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As Excel.Workbook

...which obviously won't work.  How else can I go about it?  Or, what's the 
bare minimum I could install to get this functionality?

Thanks,
Leif

-- 
Leif Bloomquist
leif(at)schemafactor(dot)com
http://home.ica.net/~leifb/

"Once secure, saturate the area with plasma mortars and spicy barbecue
sauce." 


0
Leif
1/18/2007 8:25:03 PM
comp.lang.basic.visual.misc 10153 articles. 0 followers. Post Follow

3 Replies
1203 Views

Similar Articles

[PageSpeed] 51

On Thu, 18 Jan 2007 15:25:03 -0500, "Leif Bloomquist" <spam@127.0.0.600>
wrote:

>
>Hi all,
>
>My VB6 app needs to be able to read from an Excel .xls file.  However, the 
>target computer won't have Excel installed.  All the online examples I've 
>found for reading Excel files assume you're doing this...
>
>Dim xl As Excel.Application
>Dim xlsheet As Excel.Worksheet
>Dim xlwbook As Excel.Workbook
>
>..which obviously won't work.  How else can I go about it?  Or, what's the 
Leif

Apply to Microsoft and get a licence to see the internal format of .xl?
files. 

They will want to know why you need it, but it is available (or was).

Richard
Web pages: http://www.caravanningnow.co.uk/ for caravanning,
http://www.rcole.org/ for my personal web site and
http://www.homeindorset.co.uk because I love the email address.
-- 
Top 20 Replies by Programmers When Their Programs Don't Work: 4. "You can't
use that version on your system."
0
ispcrco1 (162)
1/19/2007 6:26:33 PM
On Fri, 19 Jan 2007 18:26:33 +0000, Richard Cole
<ispcrco@hotmail.com.invalid> wrote something that piqued my interest
enough to reply with:

>Apply to Microsoft and get a licence to see the internal format of .xl?
>files. 
>
>They will want to know why you need it, but it is available (or was).
>
Both the older formats such as BIFF and newer XML formats are actually
publically available (otherwise Open Office would be in breach for
publishing almost all MS Office file formats), although most code you'll
find on the 'net that doesn't require Excel installed deals with writing
them not reading them (as writing a BIFF2.1 spreadsheet is trivial and
readable by almost all Excel versions).

Reading them without Excel being installed on the 'server' machine,
particularly when you may have to deal with multiple possible versions
(BIFF, binary, XML, etc) is not as trivial, which is why most controls
available to do that will cost you upwards of $150...I haven't seen a
free control or code to do it.

It is supposedly possible to use JET/ADO to access an XLS as if it where
a DB (similarly to the way you can access an Access MDB without Access
installed), but I've not got it to work consistently across different
versions of MS Office, or even know if it works without Excel installed
as all my  dev machines have MS Office installed; 

http://www.vbforums.com/showthread.php?t=382404

http://support.microsoft.com/kb/257819

You could try to write your own method by decompiling the file format
(which I presume is what Richard's comment refers to);

http://www.wotsit.org/search.asp?page=1&s=xls

http://sc.openoffice.org/excelfileformat.pdf

....but I don't recommend it, it's not a trivial task. If your business
is not willing to pay for a pre-built control to do it using VB6 then
you're better off looking at getting whoever generates the XLS to export
to CSV or similar so that it's more easily readable (it would be simpler
to write an export macro and build it into the user workbooks).

As to bare minimum install to make OLE work, you're going to have to
install the bulk of Excel anyway, which I guess you were trying to
avoid.
-- 
Alfie [UK]
<http://www.delphia.co.uk/>
Can fat people go skinny-dipping ?

0
alfie1 (174)
1/19/2007 10:20:48 PM
"Alfie [UK]" <alfie@mail.invalid> wrote in message 
news:4ff2r2134n31768r6ha2s1ldop54litc80@4ax.com...

> you're better off looking at getting whoever generates the XLS to export
> to CSV or similar so that it's more easily readable (it would be simpler
> to write an export macro and build it into the user workbooks).
>
> As to bare minimum install to make OLE work, you're going to have to
> install the bulk of Excel anyway, which I guess you were trying to
> avoid.

Yeah, we'd pretty much decided to go the CSV route, I just wanted to check 
out other options before making the switch.  Thanks for the info! 


0
Leif
1/26/2007 2:23:42 PM
Reply: