XBrowse and Excel

XBrowse and Excel

Postby Detlef Hoefner » Tue Feb 16, 2010 2: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: Select all  Expand view
  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
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: XBrowse and Excel

Postby nageswaragunupudi » Tue Feb 16, 2010 4: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: Select all  Expand view
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  Expand view
           oClip := TClipBoard():New()

Substitute
Code: Select all  Expand view
           oClip := TClipBoard():New(1,::oWnd)
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse and Excel

Postby Detlef Hoefner » Tue Feb 16, 2010 5: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?
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: XBrowse and Excel

Postby nageswaragunupudi » Tue Feb 16, 2010 5:19 pm

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

Yes. Thanks
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse and Excel

Postby mgsoft » Thu Feb 18, 2010 4:55 pm

Hi Nao,

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

Thanks :D
Saludos,

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

Re: XBrowse and Excel

Postby nageswaragunupudi » Fri Feb 19, 2010 1: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
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse and Excel

Postby George » Sat Mar 27, 2010 3:22 pm

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

Regards

George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Re: XBrowse and Excel

Postby mgsoft » Mon Mar 29, 2010 10:35 am

Yes, I am interested too;) Thanks
Saludos,

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

Re: XBrowse and Excel

Postby nageswaragunupudi » Mon Mar 29, 2010 11:56 am

Sample
Code: Select all  Expand view
#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: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse and Excel

Postby nageswaragunupudi » Mon Mar 29, 2010 2:30 pm

Another sample using FiveWin MsgMeter(..) function:
Code: Select all  Expand view
#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
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBrowse and Excel

Postby George » Tue Mar 30, 2010 1:55 am

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

George
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], jmartial, Marc Venken and 109 guests