TXBROWSE:REPORT - Excel key in Preview

Post Reply
User avatar
mauri.menabue
Posts: 184
Joined: Thu Apr 17, 2008 2:38 pm

TXBROWSE:REPORT - Excel key in Preview

Post by mauri.menabue »

Hi Antonio,

can you modifiy xBrowse to avoid the followin error,
1 - the user press the excel key in preview
2 - the xlsx file name request dialog appears
3 - if the user press ESC key or press button cancel
the error appears because oXlsx:cFile is empty

Code: Select all | Expand

  

   if ( oXlsx := XlsxObj( cFileXls ) ) == nil   line 10859
      ? "Xlsx libraries not linked"
      return nil
   endif

   modify
   
if empty( cFileNoExt( oXlsx:cFile ) ) return nil endif
Application

Path and name: c:\Zephir\NwCoge\Sigah.exe (32 bits)
Size: ********* bytes
Compiler version: Harbour 3.2.0dev (r2503251254)
FiveWin version: FWH 25.09
C compiler version: Borland/Embarcadero C++ 7.7 (32-bit)
Windows 10 64 Bits, version: 10.0, Build 26200

Time from start: 26 sec
Error occurred at: 24/11/2025, 22:53:31
Error description: Error BASE/1075 Parametro errato: >
Args:
[ 1] = U
[ 2] = N 4

Stack Calls

Called from: .\source\function\fwxlsxlb.prg => (b)TWORKSHEET_SETARRAYDATA( 532 )
Called from: => AEVAL( 0 )
Called from: .\source\function\fwxlsxlb.prg => TWORKSHEET:SETARRAYDATA( 532 )
Called from: .\source\classes\xbrowse.prg => TXBROWSE:TOXLSX( 10889 )
Called from: .\source\classes\xbrowse.prg => TXBROWSE:TOEXCEL( 10975 )
Called from: .\source\classes\xbrowse.prg => (b)TXBROWSE_REPORT( 10571 )
Called from: .\source\classes\report.prg => TREPORT:TOEXCEL( 2124 )
Called from: .\source\classes\rpreview.prg => (b)TPREVIEW( 100 )
Called from: .\source\classes\rpreview.prg => TPREVIEW:EXPORTTOMSEXCEL( 0 )
Called from: .\source\classes\rpreview.prg => (b)TPREVIEW_BUILDBUTTONBAR( 411 )
Called from: .\source\classes\btnbmp.prg => TBTNBMP:CLICK( 816 )
Called from: .\source\classes\btnbmp.prg => TBTNBMP:LBUTTONUP( 1103 )
Called from: .\source\classes\control.prg => TCONTROL:HANDLEEVENT( 1867 )
Called from: .\source\classes\btnbmp.prg => TBTNBMP:HANDLEEVENT( 2146 )
Called from: .\source\classes\window.prg => _FWH( 3760 )
Called from: => SYSREFRESH( 0 )
Called from: .\source\function\msgrun.prg => STOPUNTIL( 70 )
Called from: .\source\classes\rpreview.prg => TPREVIEW:ACTIVATE( 179 )
Called from: .\source\classes\rpreview.prg => RPREVIEW( 1881 )
Called from: .\source\classes\report.prg => (b)TREPORT_NEW( 188 )
Called from: .\source\classes\report.prg => TREPORT:ACTIVATE( 917 )
Called from: .\source\classes\xbrowse.prg => TXBROWSE:REPORT( 10581 )
Called from: d:\servizio\prog\StdGes.prg => STDGES:GESTIONE( 5895 )
Called from: d:\servizio\prog\StdGes.prg => (b)STDGES_CREABAR( 2961 )
Called from: .\source\classes\toolbar.prg => TTOOLBAR:COMMAND( 237 )
Called from: .\source\classes\window.prg => TMDICHILD:COMMAND( 1222 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\mdichild.prg => TMDICHILD:HANDLEEVENT( 347 )
Called from: .\source\classes\window.prg => _FWH( 3760 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\window.prg => TMDIFRAME:ACTIVATE( 1178 )
Called from: prog\Main.prg => MAIN( 6680 )
TIA
Maurizio Menabue

User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TXBROWSE:REPORT - Excel key in Preview

Post by Antonio Linares »

Dear Mauri,

I am testing it using the example I provided you for dropping files on the xbrowse:

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

   local aData := { { 10000, 235000, 90, 2115 } }

   XBROWSER aData SETUP BrwSetup( oBrw )

return nil

function BrwSetup( oBrw )

   oBrw:bDropFiles = { | nRow, nCol, aFiles | XBrowser( { nRow, nCol, aFiles } ) }

return nil   

Are you able to reproduce this error on this example ? I am unable to do it.

Many thanks for your feedback :)

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
mauri.menabue
Posts: 184
Joined: Thu Apr 17, 2008 2:38 pm

Re: TXBROWSE:REPORT - Excel key in Preview

Post by mauri.menabue »

Hi Antonio,
happy birthday !

this is the test program

news that I had omitted in the initial post, the error happens when :
UseXLSXLIB(.T.), if i use excel to produce file the program work fine.

Code: Select all | Expand

   #include "FiveWin.ch"

   REQUEST XLSXLIB

*------------------------------------------------------------------------------------------------
Function GesTps
*------------------------------------------------------------------------------------------------

   LOCAL oDlg
   LOCAL oBrw
   LOCAL oFont    := tFont():new("Tahoma", 0, -12.00,,.F.,,,,.F.)
   local oCol
   local cTipoDoc := "Client"
   local nFiller  := 0
   local oBtn1
   local oBtn2

   UseXLSXLIB(.T.)

   USE ("data\customer") NEW ALIAS ("Client") 

   DEFINE DIALOG oDlg FROM 154.00 , 334.00 TO 604.00 , 820.00 ;
                 TITLE cTipoDoc ;
                 PIXEL ;
                 COLOR CLR_HBLUE ;
                 FONT oFont

   @ 2,2 XBROWSE oBrw ;
         OF oDlg ;
         PIXEL ;
         SIZE -2, -30 ;
         ALIAS ("Client");
         LINES   

   *---------------------------------------------------------
   *- Column FIRST
   *---------------------------------------------------------
   
ADD COLUMN oCol TO XBROWSE oBrw ; DATA ("Client")->FIRST; PICTURE "@!"; TITLE "First"; ALIGN LEFT ; SIZE 200.00 *--------------------------------------------------------- *- Column LAST *---------------------------------------------------------
ADD COLUMN oCol TO XBROWSE oBrw ; DATA ("Client")->LAST; PICTURE "@!"; TITLE "Last"; ALIGN LEFT ; SIZE 200.00 WITH OBJECT oBrw :nStretchCol := STRETCHCOL_LAST :CreateFromCode() END nFiller := ((oDlg:nWidth/2) - 90) / 3 @ (oDlg:nHeight/2) - 22, nFiller BUTTON oBtn1 PROMPT "Report" ; OF oDlg ; ACTION oBrw:Report(); SIZE 45.00 , 14.00 ; PIXEL ; FONT oFont; MESSAGE "Report" @ (oDlg:nHeight/2) - 22, (nFiller * 2) + oBtn1:nWidth BUTTON oBtn2 PROMPT "Annulla" ; OF oDlg ; ACTION (odlg:end()); SIZE 45.00 , 14.00 ; PIXEL ; FONT oFont; MESSAGE "Annulla" ACTIVATE DIALOG oDlg CENTER ; ON INIT (oDlg:oClient := oBrw); VALID .T. CLOSE ("Client") oFont:End()
return(NIL) //----------------------------------------------------------------------------// #pragma BEGINDUMP int _streams; #pragma ENDDUMP

Try this sample
1) Run program
2) Press report key
3) Press excel key in preview
4) at the dialog for select file name press ESC or Press button Cancel
appears this error :

Application

Path and name: d:\fwh\samples\xbrowsereport.exe (32 bits)
Size: 5,462,016 bytes
Compiler version: Harbour 3.2.0dev (r2503251254)
FiveWin version: FWH 25.09
C compiler version: Borland/Embarcadero C++ 7.7 (32-bit)
Windows 11 64 Bits, version: 6.2, Build 9200

Time from start: 8 sec
Error occurred at: 11/26/25, 21:41:00
Error description: Error BASE/1075 Argument error: >
Args:
[ 1] = U
[ 2] = N 11

Stack Calls

Called from: .\source\function\fwxlsxlb.prg => (b)TWORKSHEET_SETARRAYDATA( 532 )
Called from: => AEVAL( 0 )
Called from: .\source\function\fwxlsxlb.prg => TWORKSHEET:SETARRAYDATA( 532 )
Called from: .\source\classes\xbrowse.prg => TXBROWSE:TOXLSX( 10889 )
Called from: .\source\classes\xbrowse.prg => TXBROWSE:TOEXCEL( 10975 )
Called from: .\source\classes\xbrowse.prg => (b)TXBROWSE_REPORT( 10571 )
Called from: .\source\classes\report.prg => TREPORT:TOEXCEL( 2124 )
Called from: .\source\classes\rpreview.prg => (b)TPREVIEW( 100 )
Called from: .\source\classes\rpreview.prg => TPREVIEW:EXPORTTOMSEXCEL( 0 )
Called from: .\source\classes\rpreview.prg => (b)TPREVIEW_BUILDBUTTONBAR( 411 )
Called from: .\source\classes\btnbmp.prg => TBTNBMP:CLICK( 816 )
Called from: .\source\classes\btnbmp.prg => TBTNBMP:LBUTTONUP( 1103 )
Called from: .\source\classes\control.prg => TCONTROL:HANDLEEVENT( 1867 )
Called from: .\source\classes\btnbmp.prg => TBTNBMP:HANDLEEVENT( 2146 )
Called from: .\source\classes\window.prg => _FWH( 3760 )
Called from: => SYSREFRESH( 0 )
Called from: .\source\function\msgrun.prg => STOPUNTIL( 70 )
Called from: .\source\classes\rpreview.prg => TPREVIEW:ACTIVATE( 176 )
Called from: .\source\classes\rpreview.prg => RPREVIEW( 1881 )
Called from: .\source\classes\report.prg => (b)TREPORT_NEW( 188 )
Called from: .\source\classes\report.prg => TREPORT:ACTIVATE( 917 )
Called from: .\source\classes\xbrowse.prg => TXBROWSE:REPORT( 10581 )
Called from: xbrowsereport.prg => (b)GESTPS( 70 )
Called from: .\source\classes\button.prg => TBUTTON:CLICK( 193 )
Called from: .\source\classes\control.prg => TBUTTON:HANDLEEVENT( 1831 )
Called from: .\source\classes\window.prg => _FWH( 3760 )
Called from: => SENDMESSAGE( 0 )
Called from: .\source\classes\dialog.prg => TDIALOG:COMMAND( 518 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\dialog.prg => TDIALOG:HANDLEEVENT( 1257 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\dialog.prg => TDIALOG:ACTIVATE( 325 )
Called from: xbrowsereport.prg => GESTPS( 82 )

how to fix it :

Code: Select all | Expand

ToXlsx( cFileXls, aCols ) CLASS TXBrowse

for each oCol in aCols <------------------------- line: 10870
WITH OBJECT oCol
AAdd( aStruct, { :cHeader, :cDataType, :nDataLen, :nDataDec } )
END
next

new code

for each oCol in aCols
WITH OBJECT oCol
AAdd( aStruct, { :cHeader, :cDataType, IF(valtype(:nDataLen) != 'U', :nDataLen, 0 ),;
IF(valtype(:nDataDec) != 'U', :nDataDec, 0 ) } )
END
next

in next step SetArrayData( aData, aStruct, aGroup ) CLASS TWorkSheet
AEval( aStruct, { |a,i| If( a[ 2 ] == "C" .and. a[ 3 ] > aSize[ i ], ; <--------------------------- line 531
a[ 3 ] := aSize[ i ], ) } )


Code: Select all | Expand

the element : a[3] will take on the correct value

why oCol:nDataLen .or. oCol:nDatadec are undefined ?
These two property are opional, and if i use the definition of
the columns of the browse as type :

Code: Select all | Expand

 
   *---------------------------------------------------------
   *- Column FIRST
   *---------------------------------------------------------
   
ADD COLUMN oCol TO XBROWSE oBrw ; DATA ("Client")->FIRST; PICTURE "@!"; TITLE "First"; ALIGN LEFT ; SIZE 200.00

these two prop remain undefined

I would also add this piece of code to not proceed the file name is empty

Code: Select all | Expand

 
 
   if ( oXlsx := XlsxObj( cFileXls ) ) == nil  <---------------Line 10859
      ? "Xlsx libraries not linked"
      return nil
   endif
   
insert this new code
if empty( cFileNoExt( oXlsx:cFile ) ) return nil endif

Thanks

User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TXBROWSE:REPORT - Excel key in Preview

Post by Antonio Linares »

Dear Mauri,

Ok, got it.

I have fixed it this way:

Code: Select all | Expand

   if ( oXlsx := XlsxObj( cFileXls ) ) == nil
      ? "Xlsx libraries not linked"
      return nil
   endif

   if oXlsx:cFile == ".xlsx"
      return nil
   endif 

many thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
mauri.menabue
Posts: 184
Joined: Thu Apr 17, 2008 2:38 pm

Re: TXBROWSE:REPORT - Excel key in Preview

Post by mauri.menabue »

Dear Antonio,

but in that way the problem still remains for not empty filename,
empty filename is only a collateral problem.

Thanks

Post Reply