OpenOffice Calc

OpenOffice Calc

Postby David Williams » Mon Sep 15, 2014 9:48 am

Hi

Can anyone share a code snippet to allow me to do this in Calc? In Excel, I use

oSheet:Range(aColumns[16]+"5:"+aColumns[16]+ltrim(str(nRow))):NumberFormat := "####0.0000"

I looked at ToCalc in xBrowse but I'm lost :?

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

Re: OpenOffice Calc

Postby Manuel Valdenebro » Mon Sep 15, 2014 7:28 pm

oSheet:GetCellByPosition( nCol, nRow ):CharHeight = 16 // fontsize
oSheet:GetCellByPosition( nCol, nRow ):CharWeight = 150 // bold
oSheet:GetCellByPosition( nCol, nRow ):CharColor = 0 // black


oSheet:GetCellByPosition( nCol, nRow ):SetValue := 12345 // numeric value

oSheet:GetCellByPosition( nCol, nRow ):HoriJustify=2 // center
oSheet:GetCellByPosition( nCol, nRow ):SetString= customer->NAME // string


For how to use a macro: https://suite.io/mark-alexander-bain/14pc2aa
Un saludo

Manuel
User avatar
Manuel Valdenebro
 
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Re: OpenOffice Calc

Postby anserkk » Tue Sep 16, 2014 5:17 am

If you are looking for the number formatting in OpenOffice Calc, then please refer the function GetNumberFormatId(oBook, cNumberFormat, cType) in xbrowse.prg

Code: Select all  Expand view  RUN
oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook, cNumberFormat, cType) // Returns nFormatID


Code: Select all  Expand view  RUN
// Function GetNumberFormatId(oBook, cNumberFormat, cType)
cCharLocale = oBook:GetPropertyValue("CharLocale")
nFormatId = oBook:GetNumberFormats:QueryKey(cNumberFormat, cCharLocale, .F.)

// if nFormatID is -1, then it means that this particular format is not available and you need to add the format.
// For this you can use the following code

IF nFormatId = -1 // 'Format is not yet defined
   TRY
      nFormatId = oBook:GetNumberFormats:AddNew(cNumberFormat, cCharLocale)
   CATCH
      MsgInfo( "Could not set the format"  + " " + cNumberFormat )
   END
ENDIF
 


Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: OpenOffice Calc

Postby David Williams » Tue Sep 16, 2014 4:15 pm

Thanks Guys,

I copied some code from xbrowse and it works a treat. I understand it a lot better now :D

The link is also very useful, Manuel.

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


Return to FiveWin for Harbour/xHarbour

Who is online

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