Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dates in Excel
Message
 
 
À
05/06/2006 13:56:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01127111
Message ID:
01127154
Vues:
18
>Hi Nadya,
>
>this may give you some ideas
>
>function VariableToExcel(Content, FieldType, CellReference)
>	
>	local Success
>	Success = TRUE
>
>	local x, FormatMask
>	
>	FieldType =  iif(empty(m.FieldType), vartype(m.Content), m.FieldType)
>	x = null
>	
>	do case
>	case isnull(m.Content)
>		
>	case inlist(m.FieldType, T_CHARACTER, T_MEMO)
>		x = ['] + rtrim(m.Content)
>	
>	case inlist(m.FieldType, T_DATE)
>		x = iif(empty(m.Content), '', '=date(' + transform(dtos(m.Content), '@R 9999,99,99') +  ')')
>		FormatMask = 'dd/mm/yyyy'
>		
>	case inlist(m.FieldType, T_DATETIME)
>		x =	;
>			iif(empty(m.Content), ;
>			'', ;
>			 '=date(' + transform(dtos(m.Content), '@R 9999,99,99') +  ')' ;
>			+ '+time(' + transform(right(ttoc(m.Content,1),6), '@R 99,99,99') +  ')'  ;
>			)
>		FormatMask = 'dd/mm/yyyy hh:mm:ss'
>		
>	case inlist(m.FieldType, T_CURRENCY)
>		x = m.Content
>		FormatMask = '#,###.00' + '_);[Red](' + '#,###.00' + ')'
>	
>	case inlist(m.FieldType, 'I')
>		x = m.Content
>		FormatMask = '#,###' + '_);[Red](' + '#,###' + ')'
>	
>	case inlist(m.FieldType, T_NUMERIC, T_DOUBLE)
>		x = m.Content
>		FormatMask = '#,###.00' + '_);[Red](' + '#,###.00' + ')'
>	
>	case inlist(m.FieldType, T_LOGICAL)
>		x = iif(m.Content, 'TRUE', 'FALSE')
>	
>	endcase
>	
>	do case
>	case (vartype(m.CellReference) <> T_OBJECT)
>		Success = FALSE
>		
>	case isnull(m.x)
>		x = ''
>	
>	otherwise
>		with m.CellReference
>				.Value = m.x
>			
>			if( !empty(m.FormatMask) )
>				.NumberFormat = m.FormatMask
>			endif
>		endwith
>	endcase
>	
>	return m.Success
>endfunc
>*--------------------------------------------------------------------------
>
Very nice. Now I need SSN as 000-00-0000, but it doesn't work. What should I do?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform