xBrowse oBw:ToExcel()
Posted: Tue Dec 15, 2015 12:58 pm
To escape from error if ListSeparator is changed on the PC i use this function GetListSeparator() in xBrowse class
cFormula:= "SUBTOTAL(" + ;
LTrim( Str( FW_DeCode( IfNil( oCol:nFooterType, 0 ), AGGR_SUM, 9, AGGR_MAX, 4, AGGR_MIN, 5, ;
AGGR_COUNT, 3, AGGR_AVG, 1, AGGR_STDEV, 7, AGGR_STDEVP, 8, 9 ) ) ) + ;
// "," + ;
GetListSeparator() + ;
oSheet:Range( oSheet:Cells( 2, nCol ), ;
oSheet:Cells( nRow - 1, nCol ) ):Address( .f., .f. ) + ;
")"
Best regards,
cFormula:= "SUBTOTAL(" + ;
LTrim( Str( FW_DeCode( IfNil( oCol:nFooterType, 0 ), AGGR_SUM, 9, AGGR_MAX, 4, AGGR_MIN, 5, ;
AGGR_COUNT, 3, AGGR_AVG, 1, AGGR_STDEV, 7, AGGR_STDEVP, 8, 9 ) ) ) + ;
// "," + ;
GetListSeparator() + ;
oSheet:Range( oSheet:Cells( 2, nCol ), ;
oSheet:Cells( nRow - 1, nCol ) ):Address( .f., .f. ) + ;
")"
Code: Select all
//----------------------------------------------------------------------------//
/*
New Function GetListSeparator()
used to return "List Separator" from "Regional and Language Options"
This character is used in oBw:ToExcel() METHOD
by default in XBROWSE.PRG is ","
but if it is changed in "Regional and Language Options" for example with "|"
program crash
*/
Function GetListSeparator() // Returning "List Separator" from "Regional and Language Options"
// Managing Register services from FiveWin
#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#define HKEY_PERFORMANCE_DATA 2147483652
#define HKEY_CURRENT_CONFIG 2147483653
#define HKEY_DYN_DATA 2147483654
local cListSeparator := "," // Default value
local hKey, cName, uValue, n := 0
if RegOpenKey( HKEY_CURRENT_USER,;
"Control Panel\International", @hKey ) == 0
while RegEnumValue( hKey, n++, @cName, @uValue ) == 0
if cName = "sList"
cListSeparator := left( uValue, 1 )
endif
end
endif
return cListSeparator
//----------------------------------------------------------------------------//