Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.XLS TO .DBF ??

245 views
Skip to first unread message

Mel Smith

unread,
Jul 19, 2007, 11:10:53 AM7/19/07
to
Dear Friends:

Is there a purely xHarbour procedure/method/function/lib that can read
in an Excel .wks file, and then build a .dbf file from the contents of this
.xls file ?

(I was reminded on anther newsgroup about an older ClipWks function from
Clipper 5.2e that apparently performed that function . Was it ever converted
to xHarbour ? )

TIA,

-Mel Smith


Robert Campsmith

unread,
Jul 19, 2007, 12:12:58 PM7/19/07
to
Hi Mel,

Try this... pass full source and target names including path

#define xLdbf3 8

**********************************************
FUNCTION XLS2DBF( cXlsName, cDbfName )
*
* Purpose: convert an Excel spreadsheet to a dBase III+ table

LOCAL oExcel := CREATEOBJECT( "Excel.Application" )
LOCAL oWorkBook, oSheet

oWorkBook := oExcel:WorkBooks:Open( cXlsName )
oSheet:SaveAs( cDbfName, xlDbf3 )
oWorkBook:Close( .f. )
oExcel:Quit()

RETURN( NIL )
*

-- Robert

Mack

unread,
Jul 19, 2007, 4:43:35 PM7/19/07
to

Hi Mel,

Yes, ClipWks was converted for use with xharbour. You should see a
"BCClipWks.lib" file in your xharbour lib folder. In fact I used to
use it for my Excel spreadsheets until I switched to using the oExcel
calls as I wanted to perform more then what ClipWks could handle.

The documentation is the same as the orignial.

Mack

Mel Smith

unread,
Jul 19, 2007, 5:21:17 PM7/19/07
to
Robert & Mack:

Thanks for the help !!

I'll look at both those solutions tomorrow.

Thanks again !

-Mel Smith
>


Gale Ford

unread,
Jul 19, 2007, 12:08:11 PM7/19/07
to
ClipWks has been converted and works ok. The main problem is that it
only works on older versions of the spreadsheet files.

I don't remember where to find it but I have the files if you cannot
find them.

Mel Smith

unread,
Jul 19, 2007, 8:24:41 PM7/19/07
to
Mack said:

>
> Yes, ClipWks was converted for use with xharbour. You should see a
> "BCClipWks.lib" file in your xharbour lib folder. In fact I used to
> use it for my Excel spreadsheets until I switched to using the oExcel
> calls as I wanted to perform more then what ClipWks could handle.
>
> The documentation is the same as the orignial.


Mack:

I don't have that bcclipwks.library in my xharbour\lib\directory.

I would appreciate your sending it to me at the following (coded) email
address:

medsyntel at aol dot com

Thanks a lot.

btw, I tried the pure ole way (from Robert Campsmith above) this afternoon
and got caught with the following error:

Error TOLEAUTO/-1 CO_E_CLASSSTRING: TOLEAUTO:NES
Arguments ([1]= Type: C Val: Excel:application)

From my tiny test app here are the error lines

ToleAuto: NEW(296) in module win32ole.prg
NEW(308) in module win32ole.prg

Anyway, may bccclpwks.lib will serve my purpose ??

Thanks again.

-Mel Smith


Robert Campsmith

unread,
Jul 20, 2007, 11:10:15 AM7/20/07
to
Sorry you had a problem Mel. It works as I expect and
without incident for me.
-- Robert

Mel Smith

unread,
Jul 20, 2007, 4:17:49 PM7/20/07
to
Robert said:
> Sorry you had a problem Mel. It works as I expect and without incident for
> me.
> -- Robert

Robert:

Apparently, one must have 'Excel' installed on their machine in order to
use your method.

So, I have to find another method (and I stlll havn't got the clipwks
library here to work with :)) )

I'm surprised that with all the other contributions offered, that no
guru has built an xls2dbf utility for xHarbour.

Anyway, thanks for trying to help !

-Mel Smith


Enrico Maria Giordano

unread,
Jul 20, 2007, 4:58:16 PM7/20/07
to

"Mel Smith" <meds...@aol.com> ha scritto nel messaggio
news:5gcjjhF...@mid.individual.net...

> Apparently, one must have 'Excel' installed on their machine in order
> to use your method.
>
> So, I have to find another method (and I stlll havn't got the clipwks
> library here to work with :)) )
>
> I'm surprised that with all the other contributions offered, that no
> guru has built an xls2dbf utility for xHarbour.

Try this using ADO:

FUNCTION MAIN()

LOCAL oCn := CREATEOBJECT( "ADODB.Connection" )

oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=e:\xharbour\mysheet.xls;Extended Properties='Excel 8.0'" )

oCn:Execute( "SELECT * INTO [DBASE III; Database=e:\xharbour].mydbf FROM
[Sheet1$]" )

oCn:Close()

RETURN NIL

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic


Mack

unread,
Jul 20, 2007, 5:44:45 PM7/20/07
to
On Jul 19, 7:24 pm, "Mel Smith" <medsyn...@aol.com> wrote:
> Mack said:
>
>
>
> > Yes, ClipWks was converted for use with xharbour. You should see a
> > "BCClipWks.lib" file in your xharbour lib folder. In fact I used to
> > use it for my Excel spreadsheets until I switched to using the oExcel
> > calls as I wanted to perform more then what ClipWks could handle.
>
> > The documentation is the same as the orignial.
>
> Mack:
>
> I don't have that bcclipwks.library in my xharbour\lib\directory.
>
> I would appreciate your sending it to me at the following (coded) email
> address:
>
> medsyntel at aol dot com
>
> Thanks a lot.
>

Hi Mel,

What version of xharbour are you using? If you are using xharbour
99.50, then this is the link: http://www.the-holms.org/new_clipwks.zip

If you are using xharbour v99.70 than I can zip up the files and send
them to you along with the documentation.

Gale is corret when she indicated that even though ClpWks has been re-
compiled so that it can work with xharbour, it will only support the
creation of Excel spreadsheets up to version 4, as well as not create
a spreadsheet with more than 8132 rows. This is the main reason I had
to switch to the oExcel method (as I was creating spreadsheets with
more than 30,000 rows but less than 65,535 which is the limit of rows
per tab for Excel 2002). Being able to use oExcel, gave more control
over formatting my spreadsheets with column headings, wordwrap and
this one is a neat, saving a dbf file as a spreadsheet even if it has
a memo field with the full contents of the memo field).

Mack

Gerald Drouillard

unread,
Jul 20, 2007, 5:41:38 PM7/20/07
to
You could also use openoffice in a similar manner.

--
Regards
--------------------------------------
Gerald Drouillard
Technology Architect
Drouillard & Associates, Inc.
http://www.Drouillard.ca

Robert Campsmith

unread,
Jul 23, 2007, 9:51:34 AM7/23/07
to
Mel,

You are correct, one must have the actual Excel program
installed for this method to work. For those without Excel,
I can export a dbf as .CSV, but I don't know how to do it in
reverse, sorry.

-- Robert

philippe...@gmail.com

unread,
Jun 25, 2019, 8:42:33 AM6/25/19
to
Hello,

12 years later...
Is the a ClpWks version for Harbour 3.0 ?
I downloaded the BCCLIPWKS.LIB, but can't link it with my other sources.

Thank you,

Philippe

dlzc

unread,
Jun 25, 2019, 9:31:44 AM6/25/19
to
Dear philippe...:

On Tuesday, June 25, 2019 at 5:42:33 AM UTC-7, philippe...@gmail.com wrote:
> Hello,
>
> 12 years later...
> Is the a ClpWks version for Harbour 3.0 ?
> I downloaded the BCCLIPWKS.LIB, but can't link it with
> my other sources.

There is a Harbour newsgroup. You are more likely to get Harbour-specific answers on the Harbour newsgroup.

We usually use OLE, and open a dialog with Excel directly. Harbour has the same capability. Because those old LIBs only worked with the .XLS format, and not the more current .XLSX format.

David A. Smith

philippe...@gmail.com

unread,
Jun 28, 2019, 9:33:52 AM6/28/19
to
Hi David,

It's what I thought (but didn't want to see :))
I'm "migrating" some Clipper applications to Harbour but without (if possible) modify the code... Actually, we use a third party product for screen management (HyperScreen) and I "just" rewrite the functions with the same name, but with native Clipper/Harbour code.
I'll see if I can redirect LPUT() and other functions. Perhaps generating a CSV file...

Thanks again,

Philippe

poopall

unread,
Jul 1, 2019, 3:59:23 AM7/1/19
to
You could also try writing a html file, that will generate a similar looking Excel File

It would be an lengthy explanation try looking up

https://www.w3schools.com/asp/prop_contenttype.asp


Response.ContentType = "application/vnd.ms-excel"


So basically generate a ".html file, which is really just a plain text file with some HTML tags etc, then once you have generated this file send it to your browser. The browser will see this as a excel file via the Content Type, and it will open in excel.

If excel is on the machine your Harbour prog is sitting on use the following if need be, this is just a basic example.




try
oExcel := CREATEOBJECT( "Excel.Application" )
catch oErr
Alert( "Microsoft Excel not found on this machine therefore cannot run" )
return
end


oWorkbook := oExcel:Workbooks:Add() // Add workbook
oSheet := oWorkbook:ActiveSheet() // Add Sheet

. (fill in what you need here)
.
.
.
.
..

oExcel:Visible = .T.

philippe...@gmail.com

unread,
Jul 1, 2019, 8:24:19 AM7/1/19
to
Tjank you !

Finally I think I had an illumination during last night (who said developers are lazy people ?)

As I already have the possibility to generate a CSV file, I just modified my print function to change the 'L' (exceL) to 'C' (CSV) and then I don't have to rewrite all (I pass to my print function a destination parameter : T for Text, I for print... Could have more than one destination).

It seems working...

Thanks again !

Philippe
0 new messages