ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Sat Jan 17, 2009 11:23 am

Dear Mr.Antonio,

The Code is updated on 28-Jan-2009

The code is almost ready. You may add this fuctionality to xBrowse class after verifying and ensuring that this does not cause damage to the existing xBrowse class. As you know my experience and knowledge in FiveWin is very limited and it is only few months back I have started with FiveWin, and there may be much better way of doing the coding part.
The ToCalc() method has more functionalities like "Export xBrowse Data to PDF format" or "MS Excel Format " or "HTML Format"

These are the additions required in xBrowse.Prg

A New Method
Method ToCalc( bProgress, nGroupBy, nPasteMode, aSaveAs )

Supporting Static Fuctions
STATIC FUNCTION GetPropertyValue(oService, cName, xValue ) // Creates OpenOffice ProperyValue Object
STATIC Function MakeColAlphabet(nCol) // Generate Alphabet equivalent of Column No Eg."AB"
STATIC Function GetNumberFormatId(oBook, cNumberFormat) // Set/Create OpenOffice Date & Number Format
STATIC FUNCTION CalcSubTotal(oCalc,oBook,oSheet,nGroupBy,aTotals,nRow,nCol) // To create the SubTotal and Grouping
STATIC Function PasteUnformattedText(oCalc,oBook,oSheet,aCols) // Default method used to transfer ClipBoard Data to Calc

E x p l a n a t i o n

Method ToCalc( bProgress, nGroupBy, nPasteMode, aSaveAs )
There are 2 methods to paste data to calc from clipboard to Calc
By default the value in nPasteMode is 2 ie xBrowse uses the Static function PasteUnformattedText(oCalc,oBook,oSheet,aCols) to paste/transfer xBrowse data from clipboard to calc.

IF nPasteMode 1 is used, then OpenOffice Uno:Paste technique is used. I have found that this method is much faster than the default method 2. But the problem with this method is that the OpenOffice calc will bring a Popup dialog and waits for the user to click on the Ok button to proceed further with the Paste/Transfer.

I tried a lot to find out the right API code to control this but unfortunately as it is not well documented, till now I have not got the appropriate API. I am sure that If we know the right API, we can avoid this nagging confirmation dialog and use this method as the default.
Code: Select all  Expand view
//----------------------------------------------------------------------------//
METHOD ToCalc( bProgress, nGroupBy, nPasteMode, aSaveAs ) CLASS TXBrowse

   local oCalc, oDeskTop,oBook, oSheet, oWin, oLocal, oDispatcher
   local nCol, nXCol, oCol, cType, uValue
   local uBookMark, nRow
   local nDataRows
   local aCols
   local oClip, cText, nPasteRow, nStep, cFormat,cFileName,cURL,i
   local aTotals  := {}, lAnyTotals := .f. , aProp:={} , aOOFilters:={} , nPos, oCharLocale
   DEFAULT nPasteMode:=1
   DEFAULT aSaveAs:={}

   aOOFilters:={ {"PDF","calc_pdf_Export"},{"XLS","MS Excel 97"},{"HTML","XHTML Calc File"} }

   nDataRows   := EVAL( ::bKeyCount )
   if nDataRows == 0
     return nil
   endif

   aCols         := ::GetVisibleCols()

   if Empty( aCols )
     return nil
   endif

   #ifdef __XHARBOUR__

      TRY
         oCalc   := GetActiveObject( "com.sun.star.ServiceManager" )
      CATCH
         TRY
            oCalc   := CreateObject( "com.sun.star.ServiceManager" )
         CATCH
            MsgAlert( "Open Office Calc not installed" )
            return Self
         END
      END

   #else
      oCalc   := TOLEAuto():New( "com.sun.star.ServiceManager" )
   #endif

   lxlEnglish:=.T.

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

   // Create OpenOffice Calc Instance with the Window Hidden Property
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "Hidden", .T. )  )
   oBook    := oDesktop:LoadComponentFromURL( "private:factory/scalc", "_blank", 0, aProp )
   oSheet   := oBook:GetSheets():GetByIndex( 0 )
   oDispatcher:= oCalc:CreateInstance( "com.sun.star.frame.DispatchHelper" )

   // Object to handle OpenOffice Language
   oCharLocale = oBook:GetPropertyValue("CharLocale")
   IF oCharLocale:Language == "de"  // German
      cxlSum:="=SUMME("
   ELSEIF oCharLocale:Language == "fr"  // French
      cxlSum:="=SOMME("
   ELSEIF oCharLocale:Language == "es"  // Spanish
      cxlSum:="=SUMA("
   ELSEIF oCharLocale:Language == "pt"  // Portugese
      cxlSum:="=SOMA("
   ELSEIF oCharLocale:Language == "it"  // Italian
      cxlSum:="=SOMMA("
   ELSE
      cxlSum:="=SUM("
   ENDIF


   // This routine blocks screen updating and therefore allows faster macro execution
   oBook:addActionLock()
   oBook:LockControllers()

   uBookMark   := EVAL( ::bBookMark )

   nRow   := 1
   nCol   := 0
   for nXCol := 1 TO Len( aCols )
     oCol   := aCols[ nXCol ]

     nCol ++

     oSheet:GetCellByPosition( nCol-1, nRow-1 ):SetString = oCol:cHeader
     cType      := oCol:cDataType

     DO CASE
        CASE cType == 'N'

           cFormat     := If( lThouSep, If( lxlEnglish, "#,##0", "#.##0" ), "0" )
           if oCol:cEditPicture != nil .AND. "." $ oCol:cEditPicture
              cFormat  += If( lxlEnglish, ".00", ",00"  )
           endif
           oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook, cFormat, cType)
           oSheet:GetColumns():GetByIndex( nCol-1 ):HoriJustify = 3  // 3 Right Alignement

        CASE cType == 'D'
           if lxlEnglish
             if ValType( oCol:cEditPicture ) == 'C' .and. !( oCol:cEditPicture = '@' )
                oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook,  oCol:cEditPicture, oCol:cHeader, cType )
             else
                oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook,   Set( _SET_DATEFORMAT ), oCol:cHeader, cType  )
             endif
             oSheet:GetColumns():GetByIndex( nCol-1 ):HoriJustify = 3   // 3 Right Alignment
           endif
        CASE cType == 'L'
           // leave as general format
        OTHERWISE
            oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:= "@"
     ENDCASE

   Next nXCol

   oBook:CurrentController:select( oSheet:GetCellRangeByPosition( 0, 0, Len( aCols )-1,0 ) )
   oSheet:getCellByPosition(0,0):Rows:Height=750   //1000 = 1cm


   // Draw Bottom Border Line on the Header Row
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "OuterBorder.BottomBorder", {0,0,2,0}  )        )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:SetBorderStyle", "", 0, aProp)

   // Make Header Row Font Bold
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "Bold", .T.  )        )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Bold", "", 0, aProp)

   // Make Setting for Paste Tab Delimited Text
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc,  "FilterName", "Text" ) )
   AAdd(aProp,GetPropertyValue(oCalc, "FilterOptions", "9,,MS_1257,0,2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2"   )        )

    if Empty( ::aSelected ) .or. Len( ::aSelected ) == 1

      Eval( ::bGoTop )
      if ::oRs != nil .AND. Len( aCols ) == ::oRs:Fields:Count()
            ::oRs:MoveFirst()
            nRow   := oSheet:GetCellByPosition( 2, 1 ):CopyFromRecordSet( ::oRs )
            ::oRs:MoveFirst()
         nRow   += 2
      else

         if bProgress == nil
            if ::oWnd:oMsgBar == nil
               bProgress := { || nil }
            else
               bProgress := { | n, t | ::oWnd:SetMsg( "To Calc  : " + Ltrim( Str( n ) ) + "/" + Ltrim( Str( t ) ) ) }
            endif
         endif

         nRow      := 2
         nPasteRow := 2
         nStep     := Max( 1, Min( 100, Int( nDataRows / 100 ) ) )
         cText     := ""
         oClip := TClipBoard():New()
         if oClip:Open()

            Eval( bProgress, 0, nDataRows )
            do while nRow <= ( nDataRows + 1 )
               if ! Empty( cText )
                  cText += CRLF
               endif
               cText    += ::ClpRow( .t. )

               ::Skip( 1 )             // Eval( ::bSkip, 1 )
               nRow ++

               if Len( cText ) > 16000
                  oClip:SetText( cText )
                  oBook:CurrentController:select( oSheet:GetCellByPosition( 0,nPasteRow-1 ) )
                  IF nPasteMode == 2
                     oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Paste", "", 0, aProp)
                  else
                     PasteUnformattedText(oCalc,oBook,oSheet,aCols)
                  Endif
                  oClip:Clear()
                  cText       := ""
                  nPasteRow   := nRow
               endif

               If ( nRow - 2 ) % nStep == 0
                  if Eval( bProgress, nRow - 2, nDataRows ) == .f.
                     Exit
                  endif
                  SysRefresh()
               endif

            enddo
            if ! Empty( cText )
               oClip:SetText( cText )
               oBook:CurrentController:select( oSheet:GetCellByPosition( 0,nPasteRow-1 ) )
               IF nPasteMode == 2
                  oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Paste", "", 0, aProp)
               else
                  PasteUnformattedText(oCalc,oBook,oSheet,aCols)
               Endif
               oClip:Clear()
               cText    := ""
            endif
            oClip:Close()

            Eval( bProgress, nDataRows, nDataRows )
            SysRefresh()

         endif
         oClip:End()
      endif
    else
      ::Copy()
      oBook:CurrentController:select( oSheet:GetCellByPosition( 2,1 ) )
      IF nPasteMode == 2
         oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Paste", "", 0, aProp)
      else
         PasteUnformattedText(oCalc,oBook,oSheet,aCols)
      Endif
      nRow := Len( ::aSelected ) + 2
   ENDIF

   nCol   := 0 ; nRow:=nRow-2
   oBook:CurrentController:select( oSheet:GetCellRangeByPosition( 0, nRow, Len( aCols )-1,nRow ) )

   // Draw Bottom Border Line on the Bottom Row
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "OuterBorder.BottomBorder", {1,1,2,1}  )        )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:SetBorderStyle", "", 0, aProp)

   if ValType( nGroupBy ) == 'N'
      for nxCol := 1 TO Len( aCols )
         if aCols[ nxCol ]:lTotal
            AAdd( aTotals, nxCol )
         endif
      next
      if ! Empty( aTotals )
         CalcSubTotal(oCalc,oBook,oSheet,nGroupBy,aTotals,nRow,Len(aCols)-1)
      Endif
   else

       // If lTotal is .T. for any column then create the formula to Show the Column Total
      for nXCol := 1 TO Len ( aCols )
         oCol   := aCols[ nXCol ]
         nCol ++
         if oCol:lTotal
            oBook:CurrentController:select( oSheet:GetCellByPosition( nCol-1,nRow+1 ) )
            aProp:={}
            *AAdd(aProp,GetPropertyValue(oCalc, "StringName","=SUM("+ oSheet:getColumns():getByIndex(nCol)+"2:"+oSheet:getColumns():getByIndex(nCol)+LTrim(Str(nRow+1))+")"  )    )
            AAdd(aProp,GetPropertyValue(oCalc, "StringName",cxlSum+ MakeColAlphabet(nCol)+"2:"+MakeColAlphabet(nCol)+LTrim(Str(nRow+1))+")"  )  )
            oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:EnterString", "", 0, aProp)
            lAnyTotals := .t.
         endif
      next nXCol
      if lAnyTotals
         oBook:CurrentController:select( oSheet:GetCellRangeByPosition( 0, nRow+1, Len( aCols )-1,nRow+1 ) )
         // Draw Bottom Border Line on the Total Line Row
         aProp:={}
         AAdd(aProp,GetPropertyValue(oCalc, "OuterBorder.BottomBorder", {1,1,2,1}  )        )
         oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:SetBorderStyle", "", 0, aProp)

         // Make the Total Line Bold
         aProp:={}
         AAdd(aProp,GetPropertyValue(oCalc, "Bold", .T.  )        )
         oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Bold", "", 0, aProp)
      ENDIF
   Endif

   oBook:CurrentController:select( oSheet:GetCellByPosition( 1,1 ) )

   for nCol := 1 to Len( aCols )
     oSheet:GetColumns():GetByIndex( nCol-1 ):OptimalWidth = .T.
   next

   oBook:CurrentController:select( oSheet:GetCellByPosition( 0,1 ) )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:FreezePanes", "", 0, {})

   Eval( ::bBookMark, uBookMark )
   ::Refresh()
   ::SetFocus()

   // This routine allows screen updating
   oBook:UnlockControllers()
   oBook:removeActionLock()


   // If you want to convert this to other formats like PDF format or MS Excel
   IF Len(aSaveAs) > 0
      FOR I:=1 TO Len(aSaveAs)
         cFormat:=Upper(aSaveAs[i][1])
         cFileName:=aSaveAs[i][2]
         * Ensure leading slash.
         IF LEFT( cFilename, 1 ) != "/"
            cFileName:= "/" + cFileName
         ENDIF

         cURL:= StrTran( cFilename, "\", "/" )   // change backslashes to forward slashes.
         cURL = "file://" + cURL

         aProp:={} ; nPos:=0
         nPos:=AScan(aOOFilters,{ |x| x[1] == cFormat})
         IF nPos > 0
            AAdd(aProp,GetPropertyValue(oCalc, "FilterName", aOOFilters[nPos][2])  )
            cURL:=cURL+"."+cFormat
            oBook:StoreToURL( cURL, aProp )
         Endif

      Next
   ENDIF
   oBook:GetCurrentController():GetFrame():GetContainerWindow():SetVisible(.T.)
   oBook:CurrentController:select( oSheet:GetCellByPosition( 0,0 ) )
*   oBook:Close(1)  // To Close OpenOffice Calc

Return Self

//----------------------------------------------------------------------------//
STATIC Function MakeColAlphabet(nCol)
  LOCAL aColumns:={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",;
                      "S","T","U","V","W","X","Y","Z"}
  LOCAL cColAphabet,nInt

  IF nCol <= 26
     cColAphabet:=aColumns[nCol]
  ELSEif nCol <= 676
     nInt:=Int(nCol/26)
     cColAphabet:=aColumns[nCol]
     cColAphabet+=aColumns[nCol-(nInt*26)]
  Endif
RETURN cColAphabet

//----------------------------------------------------------------------------//

STATIC FUNCTION GetPropertyValue(oService, cName, xValue )
   LOCAL oArg
   oArg := oService:Bridge_GetStruct( "com.sun.star.beans.PropertyValue" )
   oArg:Name  := cName
   oArg:Value := xValue
RETURN oArg

//----------------------------------------------------------------------------//

STATIC Function GetNumberFormatId(oBook, cNumberFormat, cColHeader, cDataType)
  LOCAL cCharLocale,nFormatId
  cCharLocale = oBook:GetPropertyValue("CharLocale")
  IF cDataType == "D"  // Date
      cNumberFormat:=Upper(cNumberFormat)
      IF cCharLocale:Language == "es" .or. cCharLocale:Language == "pt" .or. cCharLocale:Language == "it"  // Spanish,Portuguese,Italian,French
        cNumberFormat:=StrTran(cNumberFormat,"Y","A")  // All Y should be replaced to A
      ELSEIF cCharLocale:Language == "de"  // German
         cNumberFormat:=StrTran(cNumberFormat,"D","T")  // All D should be replaced to T
         cNumberFormat:=StrTran(cNumberFormat,"Y","J")  // All Y should be replaced to J
      elseif cCharLocale:Language == "fr"  // French
         cNumberFormat:=StrTran(cNumberFormat,"D","J")  // All D should be replaced to J
         cNumberFormat:=StrTran(cNumberFormat,"Y","A")  // All Y should be replaced to A
      Endif
  Endif
  nFormatId = oBook:GetNumberFormats:QueryKey(cNumberFormat, cCharLocale, .F.)
  IF nFormatId = -1 // 'Format is not yet defined
     TRY
        nFormatId = oBook:GetNumberFormats:AddNew(cNumberFormat, cCharLocale)
     CATCH
        MsgInfo("Could not set the format "+cNumberFormat+" to column "+cColHeader)
        IF cDataType == "D"  // Date
           nFormatId:=37
        Endif
     END
  ENDIF

RETURN nFormatId

//----------------------------------------------------------------------------//

STATIC FUNCTION CalcSubTotal(oCalc,oBook,oSheet,nGroupBy,aTotals,nRow,nCol)

   LOCAL oRange, oSubTotDesc,oColumns,aArg:={},nCount

   FOR nCount:=1 TO Len(aTotals)
      oColumns := oCalc:Bridge_GetStruct( "com.sun.star.sheet.SubTotalColumn" )
      //Description by columns : sum of 4th col should be 3, for 2 it should be 1
      oColumns:Column  := aTotals[nCount]-1
      oColumns:Function :=2 // com.sun.star.sheet.GeneralFunction.SUM
      AAdd(aArg,oColumns)
   Next

   oRange:= oSheet:getCellRangeByPosition( 0, 0, nCol,nRow )
   oSubTotDesc:=oRange:createSubTotalDescriptor(.T.)  // true  creates an empty descriptor. false previous settings

   //Group by: nGroupBy col-1
   oSubTotDesc:addNew(aArg, nGroupBy-1)
   oRange:applySubTotals(oSubTotDesc, .T.)   // true = replaces previous subtotal
Return NIL

//----------------------------------------------------------------------------//

STATIC Function PasteUnformattedText(oCalc,oBook,oSheet,aCols)
  LOCAL oClipContType,oClipContent,oClip,cStr,i,nClipColNo
  LOCAL lFound,nRow,nCol,k,oCol

  oClip = oCalc:CreateInstance("com.sun.star.datatransfer.clipboard.SystemClipboard")
  oClipContType = oClip:Contents:getTransferDataFlavors

  lFound = .F. ;   i:= 1

  DO while i <= Len(oClipContType) .AND. !lFound
    if oClipContType[i]:HumanPresentableName = "OEM/ANSI Text"
      lFound = .T.
      k:=i
    else
      i:=i + 1
    endif
  Enddo

  if lFound

    nRow   = oBook:CurrentSelection:getRangeAddress():startrow
    oClipContent:=oClip:Contents:getTransferData( oClipContType[k] )

    i:=1 ;  cStr:="" ; nCol:=0

    DO while i <= Len(oClipContent)
       if oClipContent[i] = 0 .OR. oClipContent[i] = 13 .OR. oClipContent[i] = 10
        i=i+2 ; nRow:=nRow + 1 ; cStr:="" ;  nCol:=0
     ELSEIF oClipContent[i] = 9  // Tab
        oCol:=aCols[nCol+1]

        IF oCol:cDataType == "C"
            oSheet:getCellByposition(nCol,nRow):SetString(cStr)
        ELSEIF oCol:cDataType == "N"
            oSheet:getCellByposition(nCol,nRow):SetValue(cStr)
        ELSEIF oCol:cDataType == "D"
           oSheet:getCellByposition(nCol,nRow):SetFormula(cStr)
        ELSE
           oSheet:getCellByposition(nCol,nRow):SetString(cStr)
        Endif
        nCol:=nCol+1 ; cStr:="" ; i:=i+1
      else
        cStr:=cStr + chr(oClipContent[i])
        i:=i+1
      endif
    Enddo

  endif
RETURN NIL
//----------------------------------------------------------------------------//



Thanks & Regards

Anser
Last edited by anserkk on Wed Jan 28, 2009 6:29 am, edited 15 times in total.
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby Silvio » Sat Jan 17, 2009 12:37 pm

Application
===========
Path and name: C:\work\errori\openoffice\OCalc.Exe (32 bits)
Size: 1,797,632 bytes
Time from start: 0 hours 0 mins 11 secs
Error occurred at: 17/01/2009, 13:38:07
Error description: Error com.sun.star.ServiceManager:CREATEINSTANCE:LOADCOMPONENTFROMURL:GETNUMBERFORMATS/3 DISP_E_MEMBERNOTFOUND: ADDNEW
Args:
[ 1] = C DD/MM/YYYY
[ 2] = O Object

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:ADDNEW(0)
Called from: xbrowse.prg => GETNUMBERFORMATID(5316)
Called from: xbrowse.prg => TXBROWSE:TOCALC(5118)
Called from: Test.Prg => (b)MAIN(49)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE(0)
Called from: Test.Prg => MAIN(55)
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Sat Jan 17, 2009 1:03 pm

Silvio, what's the version of OpenOffice used in your PC ? Is it 3.0.0

Here it is working fine wih OpenOffice 3.0.0
I shall try it on a different PC and let you know.

Regards

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

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby Silvio » Sat Jan 17, 2009 1:32 pm

yes I use the 3.0
build 9358
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Mon Jan 19, 2009 5:50 am

Dear Silvio,

I could not replicate the error which you have said. I tried it in differnt PC's.

What is the OS used in your PC ?. I am using XP Professional SP3. I have not tested in Vista. I don't have Vista PC for test.
Anybody here tested this code ?.

I have added few more lines to the code to Open Calc Hidden and Calc Window displayed only after processing the data in Calc.

I have edited my previous post containing the code and have updated the Code to include these lines

Code: Select all  Expand view
// Create OpenOffice Calc Instance with the Window Hidden Property
aProp:={}
AAdd(aProp,GetPropertyValue(oCalc, "Hidden", .T. )  )
oBook    := oDesktop:LoadComponentFromURL( "private:factory/scalc", "_blank", 0, aProp )


Code: Select all  Expand view
   // Display Calc window
  oBook:GetCurrentController():GetFrame():GetContainerWindow():SetVisible(.T.)
Return Self


Regards

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

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby Silvio » Mon Jan 19, 2009 9:44 am

I try a the test with different pc ( w2000 e wxp sp2)
with 2gb or 4 gb

same error


I NOT KNOW WHY ?

WHY ANTONIO and NAS TELL us What we must do ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Mon Jan 19, 2009 9:59 am

Silvio,

Can you remove the following line from the Test.Prg and try

Code: Select all  Expand view
Set Date British


Please let me know the status

The Function GetNumberFormatId() is suppose to check whether a particular date/number format exists in OpenOffice and if the format does not exist then it will add as a new format and will give the Numerical ID associated with that particular format

Regards

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

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Mon Jan 19, 2009 12:36 pm

Hi all,

Modified the Method ToCalc() to save xBrowse data as PDF or Excel or HTML. We can add more options by adding the OpenOffice filters to the array aOOFilters

aOOFilters:={ {"PDF","calc_pdf_Export"},{"XLS","MS Excel 97"},{"HTML","XHTML Calc File"} }

Code: Select all  Expand view
aSaveAs:={ {"PDF" ,"C:\Documents and Settings\anser\Desktop\Test"},;
           {"XLS" ,"C:\Documents and Settings\anser\Desktop\Test"},;
           {"HTML","C:\Documents and Settings\anser\Desktop\Test"} }
oBrw:ToCalc(,2,1,aSaveAs)


I have edited my previous post containing the code and have updated the Code to include the following lines

Code: Select all  Expand view
// If you want to convert this to other formats like PDF format or MS Excel
IF Len(aSaveAs) > 0
   FOR I:=1 TO Len(aSaveAs)
      cFormat:=Upper(aSaveAs[i][1])
      cFileName:=aSaveAs[i][2]
      * Ensure leading slash.
      IF LEFT( cFilename, 1 ) != "/"
         cFileName:= "/" + cFileName
      ENDIF

      cURL:= StrTran( cFilename, "\", "/" )   // change backslashes to forward slashes.
      cURL = "file://" + cURL

      aProp:={} ; nPos:=0
      nPos:=AScan(aOOFilters,{ |x| x[1] == cFormat})
      IF nPos > 0
         AAdd(aProp,GetPropertyValue(oCalc, "FilterName", aOOFilters[nPos][2])  )
         cURL:=cURL+"."+cFormat
         oBook:StoreToURL( cURL, aProp )
      Endif

   Next
ENDIF


Regards

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

Re: ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Wed Jan 21, 2009 5:43 pm

Dear Mr.Antonio,

After testing at your end, Can you please include this new method in xBrowse class in the FWH distribution.

I have not tested in Vista. In XP and Win2000 it is working fine.

Regards

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

Re: ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Postby Silvio » Wed Jan 21, 2009 6:12 pm

Application
===========
Path and name: C:\work\errori\openoffice\OCalc.Exe (32 bits)
Size: 1,797,632 bytes
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 21/01/2009, 19:11:36
Error description: Error com.sun.star.ServiceManager:CREATEINSTANCE:LOADCOMPONENTFROMURL:GETNUMBERFORMATS/3 DISP_E_MEMBERNOTFOUND: ADDNEW
Args:
[ 1] = C dd/mm/yyyy
[ 2] = O Object

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:ADDNEW(0)
Called from: xbrowse.prg => GETNUMBERFORMATID(5316)
Called from: xbrowse.prg => TXBROWSE:TOCALC(5118)
Called from: Test.Prg => (b)MAIN(49)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE(0)
Called from: Test.Prg => MAIN(55)










I have this error with :

WINDOWS XP PROFESSIONALE SERVER PACK 3
OPEN OFFICE 3.0

this is my source test
Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"

*-----------------------------------------*
Function Main()
*-----------------------------------------*
Local oDlg,oBrw,oBar,aClrCol

Set Date British
Set Century ON

Sele A
Use Test
Set Date British
SetBalloon( .t. )

DEFINE WINDOW oDlg TITLE "Testing Open Office support in TxBrowse" FROM 1,5 to 35.2,95

@ 0, 0 XBROWSE oBrw OF oDlg;  // LINES CELL
     COLUMNS 'FIRST','LAST','HIREDATE','SALARY' ;
     HEADERS 'First Name','Last Name','Hire.Dt','Salary';
     ALIAS 'Test' ;
     FOOTERS CELL


oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLROWRC // MARQSTYLE_HIGHLROWMS MS can be used to place rec point on a partucular record and move futher using mouse scroll
oBrw:nColDividerStyle    := LINESTYLE_LIGHTGRAY
oBrw:lColDividerComplete := .t.

oBrw:nRowHeight := 20  // Height between lines
oBrw:nHeaderHeight := 30

// Changing Row-Colors
aClrCol := { { 0, nRGB(192,221,255) }, { 0, nRGB(221,245,255) } }
oBrw:bClrStd := { || aClrCol[ oBrw:KeyNo % 2 + 1 ] }
oBrw:CreateFromCode()
oDlg:oClient := oBrw

DEFINE BUTTONBAR oBar OF oBrw:oWnd SIZE 56,64 2007

DEFINE BUTTON OF oBar ;
  PROMPT "Excel" ;
  TOOLTIP { "Export to Excel", "Excel" } ;
  ACTION oBrw:ToExcel()

DEFINE BUTTON OF oBar ;
  PROMPT "Calc" ;
  TOOLTIP { "Export to OpenOffice Calc", "Calc" } ;
  ACTION oBrw:ToCalc()


set message   to  " test xbrowse" of oDlg 2007

ACTIVATE WINDOW oDlg ON INIT oBrw:SetFocus();

Close Data
Return NIL



this is the method tocalc() I have
Code: Select all  Expand view
METHOD ToCalc( bProgress, nGroupBy, nPasteMode ) CLASS TXBrowse

   local oCalc, oDeskTop,oBook, oSheet, oWin, oLocal, oDispatcher
   local nCol, nXCol, oCol, cType, uValue
   local uBookMark, nRow
   local nDataRows
   local aCols
   local oClip, cText, nPasteRow, nStep, cFormat
   local aTotals  := {}, lAnyTotals := .f. ; aProp:={}
   DEFAULT nPasteMode:=1

   nDataRows   := EVAL( ::bKeyCount )
   if nDataRows == 0
     return nil
   endif

   aCols         := ::GetVisibleCols()

   if Empty( aCols )
     return nil
   endif

   #ifdef __XHARBOUR__

      TRY
         oCalc   := GetActiveObject( "com.sun.star.ServiceManager" )
      CATCH
         TRY
            oCalc   := CreateObject( "com.sun.star.ServiceManager" )
         CATCH
            MsgAlert( "Open Office Calc not installed" )
            return Self
         END
      END

   #else
      oCalc   := TOLEAuto():New( "com.sun.star.ServiceManager" )
   #endif

   lxlEnglish:=.T.

   oDesktop := oCalc:CreateInstance( "com.sun.star.frame.Desktop" )
   oBook    := oDesktop:LoadComponentFromURL( "private:factory/scalc", "_blank", 0, {} )
   oSheet   := oBook:GetSheets():GetByIndex( 0 )
   oDispatcher:= oCalc:CreateInstance( "com.sun.star.frame.DispatchHelper" )

   // This routine blocks screen updating and therefore allows faster macro execution
   oBook:addActionLock()
   oBook:LockControllers()

   uBookMark   := EVAL( ::bBookMark )

   nRow   := 1
   nCol   := 0
   for nXCol := 1 TO Len( aCols )
     oCol   := aCols[ nXCol ]

     nCol ++

     oSheet:GetCellByPosition( nCol-1, nRow-1 ):SetString = oCol:cHeader
     cType      := oCol:cDataType

     DO CASE
        CASE cType == 'N'

           cFormat     := If( lThouSep, If( lxlEnglish, "#,##0", "#.##0" ), "0" )
           if oCol:cEditPicture != nil .AND. "." $ oCol:cEditPicture
              cFormat  += If( lxlEnglish, ".00", ",00"  )
           endif
           oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook, cFormat)
           oSheet:GetColumns():GetByIndex( nCol-1 ):HoriJustify = 3  // 3 Right Alignement

        CASE cType == 'D'
           if lxlEnglish
             if ValType( oCol:cEditPicture ) == 'C' .and. !( oCol:cEditPicture = '@' )
                oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook,  oCol:cEditPicture  )
             else
                oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:=GetNumberFormatId(oBook,  Set( _SET_DATEFORMAT )  )
             endif
             oSheet:GetColumns():GetByIndex( nCol-1 ):HoriJustify = 3   // 3 Right Alignment
           endif
        CASE cType == 'L'
           // leave as general format
        OTHERWISE
            oSheet:GetColumns():GetByIndex( nCol-1 ):NumberFormat:= "@"
     ENDCASE

   Next nXCol

   oBook:CurrentController:select( oSheet:GetCellRangeByPosition( 0, 0, Len( aCols )-1,0 ) )
   oSheet:getCellByPosition(0,0):Rows:Height=750   //1000 = 1cm


   // Draw Bottom Border Line on the Header Row
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "OuterBorder.BottomBorder", {0,0,2,0}  )        )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:SetBorderStyle", "", 0, aProp)

   // Make Header Row Font Bold
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "Bold", .T.  )        )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Bold", "", 0, aProp)

   // Make Setting for Paste Tab Delimited Text
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc,  "FilterName", "Text" ) )
   AAdd(aProp,GetPropertyValue(oCalc, "FilterOptions", "9,,MS_1257,0,2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2"   )        )




     // Create OpenOffice Calc Instance with the Window Hidden Property
aProp:={}
AAdd(aProp,GetPropertyValue(oCalc, "Hidden", .T. )  )
oBook    := oDesktop:LoadComponentFromURL( "private:factory/scalc", "_blank", 0, aProp )









    if Empty( ::aSelected ) .or. Len( ::aSelected ) == 1

      Eval( ::bGoTop )
      if ::oRs != nil .AND. Len( aCols ) == ::oRs:Fields:Count()
            ::oRs:MoveFirst()
            nRow   := oSheet:GetCellByPosition( 2, 1 ):CopyFromRecordSet( ::oRs )
            ::oRs:MoveFirst()
         nRow   += 2
      else

         if bProgress == nil
            if ::oWnd:oMsgBar == nil
               bProgress := { || nil }
            else
               bProgress := { | n, t | ::oWnd:SetMsg( "To Calc  : " + Ltrim( Str( n ) ) + "/" + Ltrim( Str( t ) ) ) }
            endif
         endif

         nRow      := 2
         nPasteRow := 2
         nStep     := Max( 1, Min( 100, Int( nDataRows / 100 ) ) )
         cText     := ""
         oClip := TClipBoard():New()
         if oClip:Open()

            Eval( bProgress, 0, nDataRows )
            do while nRow <= ( nDataRows + 1 )
               if ! Empty( cText )
                  cText += CRLF
               endif
               cText    += ::ClpRow( .t. )

               ::Skip( 1 )             // Eval( ::bSkip, 1 )
               nRow ++

               if Len( cText ) > 16000
                  oClip:SetText( cText )
                  oBook:CurrentController:select( oSheet:GetCellByPosition( 0,nPasteRow-1 ) )
                  IF nPasteMode == 2
                     oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Paste", "", 0, aProp)
                  else
                     PasteUnformattedText(oCalc,oBook,oSheet,aCols)
                  Endif
                  oClip:Clear()
                  cText       := ""
                  nPasteRow   := nRow
               endif

               If ( nRow - 2 ) % nStep == 0
                  if Eval( bProgress, nRow - 2, nDataRows ) == .f.
                     Exit
                  endif
                  SysRefresh()
               endif

            enddo
            if ! Empty( cText )
               oClip:SetText( cText )
               oBook:CurrentController:select( oSheet:GetCellByPosition( 0,nPasteRow-1 ) )
               IF nPasteMode == 2
                  oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Paste", "", 0, aProp)
               else
                  PasteUnformattedText(oCalc,oBook,oSheet,aCols)
               Endif
               oClip:Clear()
               cText    := ""
            endif
            oClip:Close()

            Eval( bProgress, nDataRows, nDataRows )
            SysRefresh()

         endif
         oClip:End()
      endif
    else
      ::Copy()
      oBook:CurrentController:select( oSheet:GetCellByPosition( 2,1 ) )
      IF nPasteMode == 2
         oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Paste", "", 0, aProp)
      else
         PasteUnformattedText(oCalc,oBook,oSheet,aCols)
      Endif
      nRow := Len( ::aSelected ) + 2
   ENDIF

   nCol   := 0 ; nRow:=nRow-2
   oBook:CurrentController:select( oSheet:GetCellRangeByPosition( 0, nRow, Len( aCols )-1,nRow ) )

   // Draw Bottom Border Line on the Bottom Row
   aProp:={}
   AAdd(aProp,GetPropertyValue(oCalc, "OuterBorder.BottomBorder", {1,1,2,1}  )        )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:SetBorderStyle", "", 0, aProp)

   if ValType( nGroupBy ) == 'N'
      for nxCol := 1 TO Len( aCols )
         if aCols[ nxCol ]:lTotal
            AAdd( aTotals, nxCol )
         endif
      next
      if ! Empty( aTotals )
         CalcSubTotal(oCalc,oBook,oSheet,nGroupBy,aTotals,nRow,Len(aCols)-1)
      Endif
   else

       // If lTotal is .T. for any column then create the formula to Show the Column Total
      for nXCol := 1 TO Len ( aCols )
         oCol   := aCols[ nXCol ]
         nCol ++
         if oCol:lTotal
            oBook:CurrentController:select( oSheet:GetCellByPosition( nCol-1,nRow+1 ) )
            aProp:={}
            AAdd(aProp,GetPropertyValue(oCalc, "StringName","=SUM("+ MakeColAlphabet(nCol)+"2:"+MakeColAlphabet(nCol)+LTrim(Str(nRow+1))+")"  )        )
            oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:EnterString", "", 0, aProp)
            lAnyTotals := .t.
         endif
      next nXCol
      if lAnyTotals
         oBook:CurrentController:select( oSheet:GetCellRangeByPosition( 0, nRow+1, Len( aCols )-1,nRow+1 ) )
         // Draw Bottom Border Line on the Total Line Row
         aProp:={}
         AAdd(aProp,GetPropertyValue(oCalc, "OuterBorder.BottomBorder", {1,1,2,1}  )        )
         oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:SetBorderStyle", "", 0, aProp)

         // Make the Total Line Bold
         aProp:={}
         AAdd(aProp,GetPropertyValue(oCalc, "Bold", .T.  )        )
         oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:Bold", "", 0, aProp)
      ENDIF
   Endif

   *****************
   oBook:CurrentController:select( oSheet:GetCellByPosition( 1,1 ) )

   for nCol := 1 to Len( aCols )
     oSheet:GetColumns():GetByIndex( nCol-1 ):OptimalWidth = .T.
   next

   oBook:CurrentController:select( oSheet:GetCellByPosition( 0,1 ) )
   oDispatcher:ExecuteDispatch(oBook:GetCurrentController():GetFrame(), ".uno:FreezePanes", "", 0, {})

   Eval( ::bBookMark, uBookMark )
   ::Refresh()
   ::SetFocus()

   // This routine allows screen updating
   oBook:UnlockControllers()
   oBook:removeActionLock()

Return Self

//----------------------------------------------------------------------------//

STATIC FUNCTION GetPropertyValue(oService, cName, xValue )
   LOCAL oArg
   oArg := oService:Bridge_GetStruct( "com.sun.star.beans.PropertyValue" )
   oArg:Name  := cName
   oArg:Value := xValue
RETURN oArg

//----------------------------------------------------------------------------//
STATIC Function GetNumberFormatId(oBook, cNumberFormat)
  LOCAL cCharLocale,nFormatId
  cCharLocale = oBook:GetPropertyValue("CharLocale")
  nFormatId = oBook:GetNumberFormats:QueryKey(cNumberFormat, cCharLocale, .F.)

  IF nFormatId = -1 // 'Format is not yet defined
     nFormatId = oBook:GetNumberFormats:AddNew(cNumberFormat, cCharLocale)
  Endif
RETURN nFormatId

//----------------------------------------------------------------------------//
STATIC Function MakeColAlphabet(nCol)
  LOCAL aColumns:={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",;
                      "S","T","U","V","W","X","Y","Z"}
  LOCAL cColAphabet,nInt

  IF nCol <= 26
     cColAphabet:=aColumns[nCol]
  ELSEif nCol <= 676
     nInt:=Int(nCol/26)
     cColAphabet:=aColumns[nCol]
     cColAphabet+=aColumns[nCol-(nInt*26)]
  Endif
RETURN cColAphabet

//----------------------------------------------------------------------------//
STATIC FUNCTION CalcSubTotal(oCalc,oBook,oSheet,nGroupBy,aTotals,nRow,nCol)

   LOCAL oRange, oSubTotDesc,oColumns,aArg:={},nCount

   FOR nCount:=1 TO Len(aTotals)
      oColumns := oCalc:Bridge_GetStruct( "com.sun.star.sheet.SubTotalColumn" )
      //Description by columns : sum of 4th col should be 3, for 2 it should be 1
      oColumns:Column  := aTotals[nCount]-1
      oColumns:Function :=2 // com.sun.star.sheet.GeneralFunction.SUM
      AAdd(aArg,oColumns)
   Next

   oRange:= oSheet:getCellRangeByPosition( 0, 0, nCol,nRow )
   oSubTotDesc:=oRange:createSubTotalDescriptor(.T.)  // true  creates an empty descriptor. false previous settings

   //Group by: nGroupBy col-1
   oSubTotDesc:addNew(aArg, nGroupBy-1)
   oRange:applySubTotals(oSubTotDesc, .T.)   // true = replaces previous subtotal
Return


//----------------------------------------------------------------------------//
STATIC Function PasteUnformattedText(oCalc,oBook,oSheet,aCols)
  LOCAL oClipContType,oClipContent,oClip,cStr,i,nClipColNo
  LOCAL lFound,nRow,nCol,k,oCol

  oClip = oCalc:CreateInstance("com.sun.star.datatransfer.clipboard.SystemClipboard")
  oClipContType = oClip:Contents:getTransferDataFlavors

  lFound = .F. ;   i:= 1

  DO while i <= Len(oClipContType) .AND. !lFound
    if oClipContType[i]:HumanPresentableName = "OEM/ANSI Text"
      lFound = .T.
      k:=i
    else
      i:=i + 1
    endif
  Enddo

  if lFound

    nRow   = oBook:CurrentSelection:getRangeAddress():startrow
    oClipContent:=oClip:Contents:getTransferData( oClipContType[k] )

    i:=1 ;  cStr:="" ; nCol:=0

    DO while i <= Len(oClipContent)
       if oClipContent[i] = 0 .OR. oClipContent[i] = 13 .OR. oClipContent[i] = 10
        oCol:=aCols[nCol+1]

        IF oCol:cDataType == "C"
           oSheet:getCellByposition(nCol,nRow):SetString(cStr)
        ELSEIF oCol:cDataType == "N"
           oSheet:getCellByposition(nCol,nRow):SetValue(cStr)
        ELSEIF oCol:cDataType == "D"
           oSheet:getCellByposition(nCol,nRow):SetFormula(cStr)
        else
           oSheet:getCellByposition(nCol,nRow):SetString(cStr)
        Endif
        i=i+2 ; nRow:=nRow + 1 ; cStr:="" ;  nCol:=0
     ELSEIF oClipContent[i] = 9  // Tab
        oCol:=aCols[nCol+1]

        IF oCol:cDataType == "C"
            oSheet:getCellByposition(nCol,nRow):SetString(cStr)
        ELSEIF oCol:cDataType == "N"
            oSheet:getCellByposition(nCol,nRow):SetValue(cStr)
        ELSEIF oCol:cDataType == "D"
           oSheet:getCellByposition(nCol,nRow):SetFormula(cStr)
        ELSE
           oSheet:getCellByposition(nCol,nRow):SetString(cStr)
        Endif
        nCol:=nCol+1 ; cStr:="" ; i:=i+1
      else
        cStr:=cStr + chr(oClipContent[i])
        i:=i+1
      endif
    Enddo

  endif
RETURN NIL


I think it also not ready to pubblish !!!!!!!!!!!!!
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Thu Jan 22, 2009 4:43 am

anserkk wrote:Silvio,

Can you remove the following line from the Test.Prg and try

Code: Select all  Expand view
Set Date British


Please let me know the status

The Function GetNumberFormatId() is suppose to check whether a particular date/number format exists in OpenOffice and if the format does not exist then it will add as a new format and will give the Numerical ID associated with that particular format


Can you let me know the status.

Here it is working fine, I tested atleast in 10 different PC's running on OS XP and Win2000. I have not tested in Vista.

Have you doen the OpenOffice installation with the default settings ? Or have you tweaked any options.

This is my Language settings (Default one) Calc->Tools->Options->LanguageSettings TreeNode
Image

I even tested after changing from default to other regions. What is the Locale settings in your Installation ?

Anybody else tested ?

Regards

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

Re: ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Postby StefanHaupt » Thu Jan 22, 2009 9:32 am

Anser,

it´s working with the german version of OpenOffice 3, if I set date german. Only the date column shows a curious format
DD.06.YYYY
.
I see the function CalcSubTotal() does not return a value, shouldn´t it return one ?

Silvio, did you set the dateformat to the language of your OpenOffice ?

It´s not working with a wrong dateformat !
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Postby anserkk » Thu Jan 22, 2009 10:22 am

StefanHaupt wrote:It´s also not working with the german version of OpenOffice 3 :(

Dear Stefan,

Are you getting the same error as said by Silvio
ie
Error description: Error
com.sun.star.ServiceManager:CREATEINSTANCE:LOADCOMPONENTFROMURL:GETNUMBERFORMATS/3 DISP_E_MEMBERNOTFOUND: ADDNEW
Args:
[ 1] = C dd/mm/yyyy
[ 2] = O Object


I am using the English version and have not tested in other language installation. Anyway I am downloading the German version and shall test. Still I wonder why such an error is happening when I call an API command to add the Date/Number format to the OpenOffice.

Thankyou for the information.

Regards

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

Re: ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Postby Silvio » Thu Jan 22, 2009 10:26 am

I ERASE ALSO THIS LINE : Set Date British

IT MAKE ERROR

THIS IS MY DIALOG OPTION :

Image


THIS IS THE PICTURE OF THE CALC AFTER i RUN THE TEST

Image

THIS MY ERROR

Code: Select all  Expand view
Application
===========
   Path and name: C:\work\errori\openoffice\OCalc.Exe (32 bits)
   Size: 1,797,632 bytes
   Time from start: 0 hours 0 mins 3 secs
   Error occurred at: 01/22/09, 11:24:33
   Error description: Error com.sun.star.ServiceManager:CREATEINSTANCE:LOADCOMPONENTFROMURL:CURRENTCONTROLLER/3  DISP_E_MEMBERNOTFOUND: SELECT
   Args:
     [   1] = O   Object

Stack Calls
===========
   Called from: source\rtl\win32ole.prg => TOLEAUTO:SELECT(0)
   Called from: xbrowse.prg => TXBROWSE:TOCALC(5202)
   Called from: Test.Prg => (b)MAIN(49)
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(0)
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(0)
   Called from:  => TWINDOW:HANDLEEVENT(0)
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(0)
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(0)
   Called from: .\source\classes\WINDOW.PRG => _FWH(0)
   Called from:  => WINRUN(0)
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE(0)
   Called from: Test.Prg => MAIN(55)
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

Postby StefanHaupt » Thu Jan 22, 2009 10:27 am

Anser,
I just edited my last post, we were posting at the same time :D

Here is it again

it´s working with the german version of OpenOffice 3, if I set date german. Only the date column shows a curious format
DD.06.YYYY


I see the function CalcSubTotal() does not return a value, shouldn´t it return one ?
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

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