>>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 >>*-------------------------------------------------------------------------- >>>
FormatMask = '000-00-0000' && seems to do the job