FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Creating a spreadsheet using Open Office
Posts: 82
Joined: Fri Mar 03, 2006 06:26 PM
Creating a spreadsheet using Open Office
Posted: Fri Sep 05, 2014 04:10 PM

Hello,

Can anybody tell me what to use for the CreateObject when creating a spreadsheet in Open Office? I have a customer who does not use Microsoft Office.

oXL := CreateObject("Excel.Application???")

TIA
David

Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: Creating a spreadsheet using Open Office
Posted: Fri Sep 05, 2014 08:11 PM

TRY
oExcel := GetActiveObject( "com.sun.star.ServiceManager" )
CATCH
TRY
oExcel := CreateObject( "com.sun.star.ServiceManager" )
CATCH
VALERT ( "OpenOffice no install", , , "X",,.t.,,{"aceptar"})
return 0
END
END

oDesktop = oExcel:CreateInstance( "com.sun.star.frame.Desktop" )

oDoc = oDesktop:LoadComponentFromURL( "private:factory/scalc", "_blank", 0, {} )
oHoja = oDoc:GetSheets():GetByIndex( 0 )
oHoja:CharFontName = "Arial"
oHoja:CharHeight = 10

oHoja:GetCellByPosition( 0, 0 ):SetString := "String text"
oHoja:GetCellByPosition( 0, 0 ):CharHeight = 16 // fontsize
oHoja:GetCellByPosition( 0, 0 ):CharWeight = 150 // bold
oHoja:GetCellByPosition( 0, 0 ):CharColor = 8388608 // blue color

Un saludo



Manuel
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Creating a spreadsheet using Open Office
Posted: Sat Sep 06, 2014 03:49 AM

Please study the METHOD ToCalc() in xbrowse.prg.
This provides a good example of creating a spread sheet with open office and exporting data to the sheet.

By the way, if MS Office is not installed and Open Office is detected, xbrowse automatically exports data to Open Office spreadsheet when we use oBrw:ToExcel()

Regards



G. N. Rao.

Hyderabad, India
Posts: 82
Joined: Fri Mar 03, 2006 06:26 PM
Re: Creating a spreadsheet using Open Office
Posted: Sat Sep 06, 2014 04:35 PM

Thanks Guys,

Just needed the keywords to search the forum.

David :)

Continue the discussion