FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Excel saveas question
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Excel saveas question
Posted: Sat Dec 08, 2007 12:42 PM

Hi Everybody,

I am trying (without success) to have my app save an excel document as an XMLSpreadsheet.

Does anyone know the correct syntax to do this?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Excel saveas question
Posted: Sat Dec 08, 2007 02:05 PM
#define adOpenForwardOnly 0
#define adOpenKeyset      1
#define adOpenDynamic     2
#define adOpenStatic      3

#define adLockReadOnly        1
#define adLockPessimistic     2
#define adLockOptimistic      3
#define adLockBatchOptimistic 4

#define adPersistXML 1


FUNCTION MAIN()

    LOCAL oRs := CREATEOBJECT( "ADODB.Recordset" )

    FERASE( "MYTEST.XML" )

    oRs:Open( "SELECT * FROM [Sheet name$]", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\xharbour\mytest.xls;Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'", adOpenForwardOnly, adLockReadOnly )

    oRs:Save( "E:\XHARBOUR\MYTEST.XML", adPersistXML )

    oRs:Close()

    RETURN NIL


EMG
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Excel saveas question
Posted: Sat Dec 08, 2007 02:43 PM

Thanks Enrico, I should have mentioned that I am using OLE to create the excel file.

Do you know how to do it with OLE?

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Excel saveas question
Posted: Sat Dec 08, 2007 06:08 PM

Save the Excel file then use my sample to convert it to XML.

EMG

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Excel saveas question
Posted: Wed Dec 12, 2007 12:07 AM

Thanks Enrico

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Excel saveas question
Posted: Wed Dec 12, 2007 02:33 PM

define xlXMLSpreadsheet 46

oBook:SaveAs( cXlsFile, xlXMLSpreadsheet ) // -4143 = Normal

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Excel saveas question
Posted: Wed Dec 12, 2007 06:42 PM

This option is not in the docs of my Excel 2000 so I think it works only on a newer version.

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Excel saveas question
Posted: Wed Dec 12, 2007 07:25 PM

Yes
Works from ver 2003

Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel saveas question
Posted: Sat Oct 22, 2011 03:44 PM
The myriad format of Excel file can really get confusing. Here's an article that might help - http://www.rondebruin.nl/saveas.htm

If for some reason need to know the office version name and it's package equivalent (e.g. Office 2003 version is 11) this wikipedia entry might help
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion