ToCalc() Method to transfer xBrowse Data to OpenOffice Calc

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

Postby Biel EA6DD » Wed Feb 18, 2009 2:52 pm

I'm Trying to use method ToCalc, but when I invoque the method ToCalc, ocurs an error.
Application
===========
Path and name: G:\fwh\Biel\EA6DDlog\EA6DDlog.Exe (32 bits)
Size: 2,203,648 bytes
Time from start: 0 hours 0 mins 16 secs
Error occurred at: 18-02-09, 13:04:12
Error description: Error TOleAuto/65535 : TOLEAUTO:NEW
Args:
[ 1] = C Excel.Application

Stack Calls
===========
Called from: .\win_tole.prg => THROW(79)
Called from: => TOLEAUTO:NEW(252)
Called from: G:\fwh\Clases no modificadas\xbrowse.prg => SETEXCELLANGUAGE(5853)
Called from: => TXBRWCOLUMN:CLPTEXT(8139)

SetExcelLanguage() is called if nxlLangID= NIL, and this function try to create object "Excel.Application", if we are using Harbour and haven't Excel ocurs the present error. With xHarbour no error because of the TRY ... CATCH.
So we can add TRY ... CATCH if compiler is harbour.
Code: Select all  Expand view
#ifdef __XHARBOUR__
         TRY
            oExcel   := GetActiveObject( "Excel.Application" )
         CATCH
            TRY
               oExcel   := CreateObject( "Excel.Application" )
            CATCH
               nxlLangID := 0
               return nil
            END
         END
         lLocal  := .t.
#else
         TRY     //<============Biel
            oExcel   := TOLEAuto():New( "Excel.Application" )
         CATCH
            nxlLangID:=0
            RETURN NIL
         END
#endif

Or really if we are working with Open Office, usually we don't have Excel installed, so we can assign 0 to nxlLangID at the begin of method ToCalc.
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:={}
   DEFAULT nxlLangId:=0  //<===Biel
 


Note to use TRY ... CATH in harbour
Code: Select all  Expand view
static bError
      #xcommand TRY              => bError := errorBlock( {|oErr| break( oErr ) } ) ;;
                                    BEGIN SEQUENCE
      #xcommand CATCH [<!oErr!>] => errorBlock( bError ) ;;
                                    RECOVER [USING <oErr>] <-oErr-> ;;
                                    errorBlock( bError )

Actually included in Fivewin.ch
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

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

Postby anserkk » Thu Feb 19, 2009 9:43 am

Dear Mr.Biel,

I have not tested the Method ToCalc() using Harbour and hence I did not receive this error. :oops:

Your suggestion is good. As you pointed out, I think we should make the following updates in xBrowse.Prg

1) In the Function SetExcelLanguage( oExcel ) TRY CATCH for HARBOUR should be implemented while trying to create Excel Object, so that the program does not quit abnormaly. Line 5853
2) In the Method ToCalc Adding the following code in Line 5037
Code: Select all  Expand view
    DEFAULT nxlLangId:=0    

3) Before leaving the Method ToCalc(), the value of nxlLangId should be made to NIL, so that it does not disturb ToExcel() in any way. (To be on the safer side) :D

If TY CATCH works in HARBOUR then I also suggest that the TRY CATCH for HARBOUR should be implemented in the Method ToExcel() where we try to create Excel Object, so that the program does not quit abnormaly Line 4834

Explanation for point no.3:

nxlLangID is a STATIC variable, and through out the PRG SetExcelLanguage() is called like the way given below
Code: Select all  Expand view
  if nxlLangID == nil
      SetExcelLanguage()
   endif
 

A numeric value is assigned to nxlLangID inside the Fuction SetExcelLanguage() based on the Installed language.

Considering a situation that a PC has both Excel and Calc installed and the user want to use both the Methods ToExcel() and ToCalc(). In this situation if we assign a value 0 to nxlLangId, I dont know what will happen when the following code gets executed from Method ToExcel()
Code: Select all  Expand view
  if nxlLangID == nil
      SetExcelLanguage()
   endif
 


May be I am not very clear with the STATIC variable declared just after the #Include statement. I beleive the value of ststic variable will be in the memory until we quit xBrowse.

Mr.Antonio, Can I have your opinion on this, so that this can be updated in the next FWH build

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 » Tue Feb 24, 2009 7:17 am

Dear Mr.Antonio,

I have send an email to you. Hope you have received the same.

Regards

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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests