DataTable Reformatting Excel Values - UFT 23.4

When I'm importing data from Test Data Excel to UFT DataTable, the excel value "31 Oct 2020" stored as string with single quote still getting formatted to Date in UFT DataTable.

This wasn't the case with UFT 15 I was using before this. Any ideas, why? Is there any UFT setting for DataTable to fetch values as it is passed in Excel?

        

Tags:

  • 0  

    hi, there

    i cannot reproduce the same problem when i import the datatable. the format is kept.

    please kindly raise a support ticket to have more thorough investigation. 

    James

  • 0 in reply to   

    Hi James,

    Could that be due to the Trial License I'm using currently? Or is there some UFT setting that's not set for Datatable? I googled a lot but couldn't find any article related to this. 

  • 0   in reply to 

    the license type doesn't matter. and no, there's no specific setting for Datatable format. UFT changes the component by which the excel file is handled. some differences were known and we've covered all of them. 

    but again, since i don't have the problem you have, i suggest you open a ticket.

    James

  • 0 in reply to   

    Alright! Thanks for your help, James.

  • 0

    Hi,

    The UFT support has provided the solution. Instead of adding leading apostrophe in the excel file, we must do it in the script now. This is a workaround with the UFT v23 and further.

    DataTable.Value(colName, sheetName) = "'" & objSheet.Cells(row, col).Value

  • 0 in reply to 

    Hi all,

    we occurs in a similar problem with the use of json text data in which there were a datetime value in the format "yyyy-MM-ddTHH:mm:ss.fffZ" and it change the format to "dd/MM/yyyy HH:mm:ss". This is a different behaviour from 2021R1 version. I found a solution changing the international settings for the date time. I create a parametrize script that change these values (sShortDate, sTimeFormat) under "HKEY_CURRENT_USER\Control Panel\International\"

    The code is this one:

    '**************************************************************
    'Script to change the registry date time default international settings
    'Hive: HKEY_CURRENT_USER
    'RegPath: HKEY_CURRENT_USER\Control Panel\International
    'Keys: sShortDate and sTimeFormat
    'Keys Type: REG_SZ
    'Author: Massimo De Rosa
    '**************************************************************

    'Check UFT Version
    Const HKEY_LOCAL_MACHINE = &H80000002

    Const PATH_INFO = "SOFTWARE\WOW6432Node\Mercury Interactive\QuickTest Professional\MicTest\TulipAppInfo"
    Const VERSION = "Version"

    Dim strComputer : strComputer = "."
    Dim strRes : strRes = ""
    Dim UFTVer : UFTVer = ""

    Dim oReg 'StdRegProv object to read regedit - a different way from oShell.RegRead
    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & _
    "\root\default:StdRegProv")

    oReg.GetStringValue HKEY_LOCAL_MACHINE,PATH_INFO,VERSION,strRes

    UFTVer = CInt(split(strRes,".")(0))


    'If UFT is 21 then I don't need to change settings
    If instr(UFTVer, "21") > 0 Then
    Reporter.ReportEvent micPass, "Switch datetime reg keys", "No need to change datetime reg keys values - UFT Version is " & UFTVer
    ExitTest 0
    End If
    'End UFT Checkin part

    Const REG_PATH = "HKEY_CURRENT_USER\Control Panel\International\"

    Const DT_KEY = "sShortDate"
    Const TF_KEY = "sTimeFormat"

    Const TAG_ENABLE = "enable"
    Const TAG_DISABLE = "disable"

    Const DT_DISABLE = "dd-MM-yyyy"
    Const TM_DISABLE = "HH:mm:ss"

    Const DT_ENABLE = "yyyy-MM-ddT"
    Const TM_ENABLE = "HH:mm:ss.fffZ"

    Dim oShell : Set oShell = CreateObject("WScript.Shell")
    'The value of the 2 keys should have consistent pair values:
    'sShortDate = dd-MM-yyyy
    'sTimeFormat = HH:mm:ss
    ' or
    'sShortDate = yyyy-MM-ddT
    'sTimeFormat = HH:mm:ss.fffZ

    'I analyze the ActionRegKey to understand which values must be settings.
    Select Case Parameter("ActionRegKey")
    Case TAG_ENABLE: switchReg DT_ENABLE, TM_ENABLE
    Case TAG_DISABLE: switchReg DT_DISABLE, TM_DISABLE
    Case Else: Reporter.ReportEvent micFail, "Switch datetime reg keys", "The switch cannot be done due a not coherent input parameter " & vbNewLine & "Must be 'enable' or 'disable'"
    End Select

    set oShell = Nothing

    Sub switchReg(dtFmt, tmFmt)
    On error resume next
    oShell.RegWrite REG_PATH & DT_KEY, dtFmt, "REG_SZ"
    oShell.RegWrite REG_PATH & TF_KEY, tmFmt, "REG_SZ"
    If err.number = 0 Then
    Reporter.ReportEvent micPass, "Switch datetime reg keys", "The switch has been done " & vbNewLine & " new value for " & DT_KEY & " : " & dtFmt & vbNewLine & " new value for " & TF_KEY & " : " & tmFmt
    else
    Reporter.ReportEvent micFail, "Switch datetime reg keys", "The switch cannot be done due to an error in the operation: " & err.description
    End If
    On error goto 0
    End Sub

    Hope this could help.

    Ciao, Massimo.