XBrowse and Excel

Post Reply
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

XBrowse and Excel

Post by Detlef Hoefner »

Hi all,

i'm using FWH 9.12.
I want to call the method ToExcel() from xBrowse.
But it crashes with following message:

Code: Select all

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

Re: XBrowse and Excel

Post by nageswaragunupudi »

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: Select all

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: Select all

            oClip := TClipBoard():New()
Substitute

Code: Select all

            oClip := TClipBoard():New(1,::oWnd)
Regards

G. N. Rao.
Hyderabad, India
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Re: XBrowse and Excel

Post by Detlef Hoefner »

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

Re: XBrowse and Excel

Post by nageswaragunupudi »

Is 'Mr. Rao' the correct way to address you?
Yes. Thanks
Regards

G. N. Rao.
Hyderabad, India
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: XBrowse and Excel

Post by mgsoft »

Hi Nao,

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

Thanks :D
Saludos,

Eduardo
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: XBrowse and Excel

Post by nageswaragunupudi »

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
George
Posts: 710
Joined: Tue Oct 18, 2005 6:49 pm

Re: XBrowse and Excel

Post by George »

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

Regards

George
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: XBrowse and Excel

Post by mgsoft »

Yes, I am interested too;) Thanks
Saludos,

Eduardo
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: XBrowse and Excel

Post by nageswaragunupudi »

Sample

Code: Select all

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

Re: XBrowse and Excel

Post by nageswaragunupudi »

Another sample using FiveWin MsgMeter(..) function:

Code: Select all

#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
George
Posts: 710
Joined: Tue Oct 18, 2005 6:49 pm

Re: XBrowse and Excel

Post by George »

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

George
Post Reply