FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse and Excel
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
XBrowse and Excel
Posted: Tue Feb 16, 2010 02:55 PM
Hi all,

i'm using FWH 9.12.
I want to call the method ToExcel() from xBrowse.
But it crashes with following message:
Code (fw): Select all Collapse
   Error description: Error BASE/1004  Class: 'NIL' has no exported method: HWND
   Args:
     [   1] = U   

Stack Calls
===========
   Called from:  => HWND(0)
   Called from: .\source\classes\CLIPBRD.PRG => (b)TCLIPBOARD:TCLIPBOARD(26)
   Called from:  => TCLIPBOARD:OPEN(0)
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:TOEXCEL(6235)
   Called from: targets.prg => (b)MAIN(189)
is there a known issue with this method?
Thanks and regards,
Detlef
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse and Excel
Posted: Tue Feb 16, 2010 04:56 PM
I too experienced this problem occasionally (not always) when the application has only one dialog containing the xbrowse. This does not happen in a normal application having a main window open.

Temporary Workaround:
Code (fw): Select all Collapse
oBrw:lExcelCellWise := .t.

When this data is true, xbrowse does not use clip board for export to excel. This workaround should solve this problem without any change to the xbrowse.prg.

Possible fix that may solve this problem: ( Line 6234 in version 9.12. Corresponding line in other versions)
Instead of
Code (fw): Select all Collapse
            oClip := TClipBoard():New()

Substitute
Code (fw): Select all Collapse
            oClip := TClipBoard():New(1,::oWnd)
Regards



G. N. Rao.

Hyderabad, India
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
Re: XBrowse and Excel
Posted: Tue Feb 16, 2010 05:14 PM

Dear Mr. Rao,

thanks a lot for your valuable help. As usual your hint works very fine.

Thanks and kind regards,
Detlef Hoefner

btw.
I'm not common with names of people from India.
Is 'Mr. Rao' the correct way to address you?

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse and Excel
Posted: Tue Feb 16, 2010 05:19 PM
Is 'Mr. Rao' the correct way to address you?

Yes. Thanks
Regards



G. N. Rao.

Hyderabad, India
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: XBrowse and Excel
Posted: Thu Feb 18, 2010 04:55 PM

Hi Nao,

Does exportation to Excel in new versions of FWH show a progress bar or a metter?.

Thanks :D

Saludos,



Eduardo
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse and Excel
Posted: Fri Feb 19, 2010 01:27 AM

ToExcel( bProgress ) method supports user defined progress bar. If we provide a codeblock as the first parameter, ToExcel method evaluates the codeblock with two paramters ( nRowsCompleted and nTotalRows )

We can construct and initialize a progress bar and set the codeblock to update the progress bar

Regards



G. N. Rao.

Hyderabad, India
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Re: XBrowse and Excel
Posted: Sat Mar 27, 2010 03:22 PM

Hello Mr.Rao
May you post a sample code using a progress bar with ToExcel class?

Regards

George

Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: XBrowse and Excel
Posted: Mon Mar 29, 2010 10:35 AM

Yes, I am interested too;) Thanks

Saludos,



Eduardo
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse and Excel
Posted: Mon Mar 29, 2010 11:56 AM
Sample
Code (fw): Select all Collapse
#include 'fivewin.ch'
#include 'xbrowse.ch'

function Main()

   local oWnd, oBar, oBrw

   USE CUSTOMER

   DEFINE WINDOW ownd
   DEFINE BUTTONBAR oBar OF oWnd SIZE 80,32 2007
   DEFINE BUTTON OF oBar PROMPT 'Excel' ACTION Export2Excel( oBrw )
   DEFINE BUTTON OF oBar PROMPT 'Quit'  ACTION WndMain():End()
   SET MESSAGE OF oWnd TO '' 2007

   @ 0,0 XBROWSE oBrw OF oWnd ALIAS 'CUSTOMER' AUTOCOLS CELL LINES

   oBrw:CreateFromCode()
   oWnd:oClient      := oBrw

   ACTIVATE WINDOW oWnd

   CLOSE DATA

return nil

static function Export2Excel( oBrw )

   local oMeter, nActual := 0
   local oBar     := oBrw:oWnd:oMsgBar

   @ 02,10 METER oMeter VAR nActual TOTAL oBrw:KeyCount() ;
      SIZE oBar:nWidth - 10, oBar:nHeight - 4 PIXEL OF oBar

   oBrw:toExcel( { | nRow, nTotal | oMeter:Set( nRow ), .t. } )
   // note: The codeblock should return .t. to continue. If it returns .f. or nil, the export ends.
   // This can be used for stop the export half way through by the user.

   oMeter:End()

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse and Excel
Posted: Mon Mar 29, 2010 02:30 PM
Another sample using FiveWin MsgMeter(..) function:
Code (fw): Select all Collapse
#include 'fivewin.ch'
#include 'xbrowse.ch'

function Main()

   local oWnd, oBar, oBrw

   USE CUSTOMER

   DEFINE WINDOW ownd
   DEFINE BUTTONBAR oBar OF oWnd SIZE 80,32 2007
   DEFINE BUTTON OF oBar PROMPT 'Excel' ;
      ACTION MsgMeter( { |oMeter, oText, oDlg, lEnd | ;
      Export2Excel( oBrw, oMeter, oText, oDlg, @lEnd ) } )
   DEFINE BUTTON OF oBar PROMPT 'Quit'  ACTION WndMain():End()
   SET MESSAGE OF oWnd TO '' 2007

   @ 0,0 XBROWSE oBrw OF oWnd ALIAS 'CUSTOMER' AUTOCOLS CELL LINES

   oBrw:CreateFromCode()
   oWnd:oClient      := oBrw

   ACTIVATE WINDOW oWnd

   CLOSE DATA

return nil

static function Export2Excel( oBrw, oMeter, oText, oDlg, lEnd )

   oBrw:ToExcel( { |n,t| oMeter:nTotal := t, ;
                         oMeter:Set( n ), ;
                         oText:SetText( Str(n) + '/' + Str(t) ), ;
                         oDlg:Update(), .t. } )

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Re: XBrowse and Excel
Posted: Tue Mar 30, 2010 01:55 AM

Thanks Mr.Rao for posting the samples.
It's worked perfect.

George

Continue the discussion