Page 1 of 1
XBrowse and Excel
Posted: Tue Feb 16, 2010 2:55 pm
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
Re: XBrowse and Excel
Posted: Tue Feb 16, 2010 4:56 pm
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:
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
Substitute
Code: Select all
oClip := TClipBoard():New(1,::oWnd)
Re: XBrowse and Excel
Posted: Tue Feb 16, 2010 5:14 pm
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?
Re: XBrowse and Excel
Posted: Tue Feb 16, 2010 5:19 pm
by nageswaragunupudi
Is 'Mr. Rao' the correct way to address you?
Yes. Thanks
Re: XBrowse and Excel
Posted: Thu Feb 18, 2010 4:55 pm
by mgsoft
Hi Nao,
Does exportation to Excel in new versions of FWH show a progress bar or a metter?.
Thanks
Re: XBrowse and Excel
Posted: Fri Feb 19, 2010 1:27 am
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
Re: XBrowse and Excel
Posted: Sat Mar 27, 2010 3:22 pm
by George
Hello Mr.Rao
May you post a sample code using a progress bar with ToExcel class?
Regards
George
Re: XBrowse and Excel
Posted: Mon Mar 29, 2010 10:35 am
by mgsoft
Yes, I am interested too;) Thanks
Re: XBrowse and Excel
Posted: Mon Mar 29, 2010 11:56 am
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
Re: XBrowse and Excel
Posted: Mon Mar 29, 2010 2:30 pm
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
Re: XBrowse and Excel
Posted: Tue Mar 30, 2010 1:55 am
by George
Thanks Mr.Rao for posting the samples.
It's worked perfect.
George