Creating a spreadsheet using Open Office

Post Reply
User avatar
David Williams
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Creating a spreadsheet using Open Office

Post by David Williams »

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
User avatar
Manuel Valdenebro
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Re: Creating a spreadsheet using Open Office

Post by Manuel Valdenebro »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Creating a spreadsheet using Open Office

Post by nageswaragunupudi »

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
User avatar
David Williams
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Re: Creating a spreadsheet using Open Office

Post by David Williams »

Thanks Guys,

Just needed the keywords to search the forum.

David :)
Post Reply