Excel saveas question

Excel saveas question

Postby Jeff Barnes » 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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Excel saveas question

Postby Enrico Maria Giordano » Sat Dec 08, 2007 2:05 pm

Code: Select all  Expand view
#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
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Sat Dec 08, 2007 2: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Enrico Maria Giordano » Sat Dec 08, 2007 6:08 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Jeff Barnes » Wed Dec 12, 2007 12:07 am

Thanks Enrico
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby Gale FORd » Wed Dec 12, 2007 2:33 pm

#define xlXMLSpreadsheet 46

oBook:SaveAs( cXlsFile, xlXMLSpreadsheet ) // -4143 = Normal
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Enrico Maria Giordano » Wed Dec 12, 2007 6:42 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby nageswaragunupudi » Wed Dec 12, 2007 7:25 pm

Yes
Works from ver 2003
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Excel saveas question

Postby hua » Sat Oct 22, 2011 3: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 116 guests