FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE oBrw:ToExcel() ERROR
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
XBROWSE oBrw:ToExcel() ERROR
Posted: Tue Apr 17, 2012 08:45 PM
Hi everyone
This is the sample program

Code (fw): Select all Collapse
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//
REQUEST DBFCDX
//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oCol, cAlias := cGetNewAlias( "CUST" )

   USE CUSTOMER NEW ALIAS (cAlias) SHARED VIA "DBFCDX"
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 900,500 TITLE "Test"

   @ 33, 0 XBROWSE oBrw OF oDlg SIZE 400,200 PIXEL ;
           ALIAS cAlias ;
           AUTOCOLS AUTOSORT FOOTERS LINES CELL

   if !Empty( oCol := oBrw:oCol( "Salary" ) )
      oCol:nTotal    := 0
      oCol:lTotal   := .t.
      oCol:nEditType := EDIT_GET
   endif

   oBrw:MakeTotals()
   oBrw:CreateFromCode()

// oBrw:lExcelCellWise := .t.

   ACTIVATE DIALOG oDlg CENTERED ;
            ON INIT ( oBrw:SetFocus(), BtnBar(oDlg,oBrw) )

   (cAlias)->( dbCloseArea() )

return nil

//----------------------------------------------------------------------------//

static function BtnBar(oDlg,oBrw)

   local oBar, oBtn

   DEFINE BUTTONBAR oBar OF oDlg SIZE 56,64 2007

   DEFINE BUTTON OF oBar ;
      RESOURCE "EXCEL" TOP ;
      PROMPT "Excel" ;
      ACTION This:ShowPopUp() ;
      MENU ExcelMenu(oBrw) ;
      MESSAGE "Export browse contents to Excel" ;
      TOOLTIP { "Export to Excel", "Excel" }

return oBar

//----------------------------------------------------------------------------//

static function ExcelMenu(oBrw)

   local oPop

   MENU oPop POPUP 2007
      MENUITEM "Export to Excel" ACTION (cursorwait(),oBrw:ToExcel(),cursorarrow())
      MENUITEM "Export to Excel with Group Totals" ;
         WHEN ! Empty( oBrw:GetVisibleCols()[1]:cOrder ) ;
         ACTION oBrw:ToExcel(,1)
   ENDMENU

return oPop




using oBrw:ToExcel() form the menu produce next ERROR

Application
===========
Path and name: E:\FWH\samples\testxbr9.exe (32 bits)
Size: 2,001,920 bytes
Time from start: 0 hours 0 mins 4 secs
Error occurred at: 04/17/12, 22:36:19
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(6737)
Called from: testxbr9.prg => (b)EXCELMENU(66)
Called from: .\source\classes\MENU.PRG => TMENU:ACTIVATE(474)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:SHOWPOPUP(1484)
Called from: testxbr9.prg => (b)BTNBAR(55)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(466)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(660)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1489)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1455)
Called from: .\source\classes\WINDOW.PRG => _FWH(3409)
Called from: => DIALOGBOXINDIRECT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: testxbr9.prg => MAIN(35)

IF I ADD
oBrw:lExcelCellWise := .t.
to program exporting to Excel working good but
CREATING THE EXCEL FILE IS 20 TIMES SLOWER (may be more)


Any help or some sugestions please ?

Best Regards,
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE oBrw:ToExcel() ERROR
Posted: Wed Apr 18, 2012 01:53 PM

This error might occur when there is no main window in the application.
We shall fix this soon.

Meanwhile, please try this fix. ( I can not give you the line number because I do not know your FWH version )

In the method ToExcel()
Please locate the statement "oClip := TClipBoard():New()"

Please try changing it as
oClip := TClipBoard():New( 1, ::oWnd )

It would be nice, if you can give your feedback after the correction.

Regards



G. N. Rao.

Hyderabad, India
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: XBROWSE oBrw:ToExcel() ERROR
Posted: Wed Apr 18, 2012 04:11 PM
Hi Rao
and THANKS THANKS for reply
I have tested on few samples and
GONIG NICE
Probably problem is only if XBROWSE is placed on dialog ... with windows i didnt found problem
Thanks again
Regards,
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE oBrw:ToExcel() ERROR
Posted: Wed Apr 18, 2012 04:30 PM
avista wrote:Hi Rao
and THANKS THANKS for reply
I have tested on few samples and
GONIG NICE
Probably problem is only if XBROWSE is placed on dialog ... with windows i didnt found problem
Thanks again
Regards,


Thanks for the feedback. We shall include the fix in the next release.
As you said the problem is only when there is no main window in the application.
Regards



G. N. Rao.

Hyderabad, India
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: XBROWSE oBrw:ToExcel() ERROR
Posted: Fri Apr 20, 2012 07:15 AM
Hi Rao,
I am not sure anymore but i am sure that XBROWSE when is placed on DIALOG have problems with oBrw:ToExcel()
I just tested original program \fwh\samples\testxbr3.prg
in the function:
static function RddBrwAllColsDlg
i added only one line:
@ 0, 0 BUTTON 'Excel' ACTION oBrw:ToExcel( oBrw )

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

static function RddBrwAllColsDlg

   local oDlg, oBrw, oCol, cAlias := cGetNewAlias( "CUST" )

   cFunc := ProcName( 0 )

   USE CUSTOMER NEW ALIAS (cAlias) SHARED VIA "DBFCDX"
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 800,400 FONT WndMain():oFont

   @ 10,10 XBROWSE oBrw ;
            OF oDlg SIZE 380,180 PIXEL ;
            ALIAS cAlias ;
            AUTOCOLS AUTOSORT FOOTERS LINES CELL ;
            BACKGROUND 'STONE'

   oBrw:bPopUp    := { |o| ColMenu( o ) }
   AEval( oBrw:aCols, { |o| o:cToolTip := { 'Column :' + CRLF + o:cHeader, 'ToolTip' } } )

   if !Empty( oCol := oBrw:oCol( "Salary" ) )
      oCol:nTotal    := 0
      oCol:lTotal   := .t.
      oCol:nEditType := EDIT_GET
   endif

   oBrw:MakeTotals()
   oBrw:CreateFromCode()

   @  0, 0 BUTTON 'Excel' ACTION oBrw:ToExcel( oBrw )

   ACTIVATE DIALOG oDlg CENTERED ON INIT oBrw:SetFocus()

   (cAlias)->( dbCloseArea() )

return nil


When presing BUTTON "Excel" program produce another error:

Application
===========
Path and name: D:\fwh\samples\testxbr3.exe (32 bits)
Size: 2,419,200 bytes
Time from start: 0 hours 0 mins 5 secs
Error occurred at: 20-04-2012, 09:09:51
Error description: Error BASE/1004 Class: 'NUMERIC' has no exported method: EVAL
Args:
[ 1] = N 502
[ 2] = O TXBROWSE

Stack Calls
===========
Called from: => EVAL(0)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:EVAL(6357)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:TOEXCEL(6739)
Called from: testxbr3.prg => (b)RDDBRWALLCOLSDLG(643)
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK(176)
Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT(1447)
Called from: .\source\classes\WINDOW.PRG => _FWH(3409)
Called from: => SENDMESSAGE(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND(407)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT(933)
Called from: => DIALOGBOXINDIRECT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: testxbr3.prg => RDDBRWALLCOLSDLG(644)
Called from: testxbr3.prg => (b)MAINMENU(114)
Called from: .\source\classes\MENU.PRG => TMENU:COMMAND(441)
Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND(1043)
Called from: .\source\classes\MDIFRAME.PRG => TMDIFRAME:COMMAND(243)
Called from: => TMDIFRAME:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(3409)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(992)
Called from: testxbr3.prg => MAIN(42)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE oBrw:ToExcel() ERROR
Posted: Fri Apr 20, 2012 07:41 PM
Please replace
Code (fw): Select all Collapse
oBrw:ToExcel( oBrw )  // oBrw as first parameter is incorrect

with
Code (fw): Select all Collapse
oBrw:ToExcel()

Works well with dialogs also, as long as there is a main window in the application.
Regards



G. N. Rao.

Hyderabad, India
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: XBROWSE oBrw:ToExcel() ERROR
Posted: Sat Apr 21, 2012 05:51 PM

Hi Rao,
Sorry this was my bad while hurring :)
Sure oBrw cant be first parameter :)
Regards,

Continue the discussion