Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coloring cell of runtime datatable
#4
Not Solved
Hi Indranil,

It is not possible within QTP itself although I do something very similar including appending date and time to the excel sheet. When you perform the export write the full path and filename to an environment variable and at the end of the test call a function similar to below to update the formatting passing the environment variable as the file:

Code:
Function FormatExcel(cFile)
Dim xl, wb, ws, iRow
'
set xl=CreateObject("excel.application")
set wb=xl.workbooks.open (cFile)
set ws=wb.worksheets(1) ' Assume global sheet is first
xl.DisplayAlerts = False ' Supress any messages from excel

iRow = Datatable.GetRowCount                         ' Use the count of the current datasheet
For x = 1 to iRow + 1                                 ' +1 to skip the header row
    If ws.Cells(x, 2).Value = "Pass" Then         ' 2 is the column number with pass, fail
        ws.Cells(x, 2).Style = "Good"                ' Use built in excel styles for the colour
    ElseIf ws.Cells(x, 2).Value = "Fail" Then
        ws.Cells(x, 2).Style = "Bad"
    ElseIf ws.Cells(x, 2).Value = "Warning" Then
        ws.Cells(x, 2).Style = "Input"
    End If
Next

' Save and close the file
wb.SaveAs cFile, True
wb.close

set ws=nothing
set wb=nothing
set xl=nothing
'
End Function
Reply


Messages In This Thread
RE: Coloring cell of runtime datatable - by SteveS - 08-03-2012, 03:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Finding a cell Location on a datatable rhozeski 0 1,967 11-23-2014, 02:38 AM
Last Post: rhozeski
  Exporting QTP runtime datatable to SQL server during SweetyChowdhury 1 3,114 05-10-2013, 03:41 AM
Last Post: sria123
  How many ways we can use external XL sheet data import in to runtime datatable govqa 1 3,263 02-18-2009, 11:09 PM
Last Post: sreekanth chilam
  Skip a cell while QTP is reading datatable mikee 2 4,257 10-01-2008, 06:05 PM
Last Post: mikee
  Exporting the runtime value to the local datatable. blavanya 8 7,602 07-18-2008, 07:18 PM
Last Post: bc993aaa

Forum Jump:


Users browsing this thread: 1 Guest(s)