Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong count for UsedRange rows and columns in datatable.
#1
Not Solved
Hi guys,

I have a problem in exporting the testcasefile to other sheet in Datatable

Issue is:

In Datatable 3 sheets(Global,Subdriver,Report)are there.
When i execute the script qtp will import the testcase file to 'subdriver' sheet.
here it is taking correct used range row numbers and column numbers.
Before execution I formatted testcasefile.

After execution qtp will export this 'subdriver' sheet to 'Report' sheet, and it will write pass fail column then it will create a testReport file in one specific folder.

after that it will take the used range row numbers and column numbers for setting the colors for pass,Fail values.But it is giving wrong number of rows and columns.

Example:

TestReport file having 10 rows,9 columns.But it is giving 256 columns and 65563 rows.
due to this reason during script execution it is not coming out from the loop.

I am using below mentioned code.

Code:
Public Function fnResColor(testReport)
    Set xlApp=CreateObject("Excel.Application")
    Set xlBook=xlApp.WorkBooks.Open(testReport)
    Set xlSheet=xlBook.Sheets("Report")
    Col_Cnt=xlSheet.UsedRange.columns.count
    msgbox Col_Cnt
    Row_Cnt=xlSheet.UsedRange.rows.count
    msgbox Row_Cnt
    For i=1 to Row_Cnt Step 1
        Val=xlSheet.Cells(i,9).Value
        If Val="Pass" Then
            xlSheet.cells(i,9).Font.ColorIndex=10
            'xlSheet.cells(i,9).interior.Color=vbGreen
        Elseif Val="Fail" Then
            xlSheet.cells(i,9).Font.ColorIndex=3
        Elseif Val="PassFail" Then
            xlSheet.cells(i,9).Font.ColorIndex=1

            'xlSheet.cells(i,9).interior.Color=vbRed
        End If
    xlBook.Save
    xlBook.Close
    Set xlSheet=Nothing
    Set xlBook=Nothing
    Set xlApp=Nothing
End Function


How can we improve the performance?

If anyone knows the solution pls reply.

Thanks in advance!
Reply
#2
Not Solved
Is your TestReport file saved as an xlsx file, if so try saving it as an xls file instead.
Reply
#3
Not Solved
Thanks for your solution.
My testcase file is xls file and TestReport file also saved as xls file.
pls reply if you have any other solution.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Comparing two unsorted excel columns ProTester 2 2,833 09-13-2018, 02:11 PM
Last Post: ProTester
  Childobject return wrong checkbox count.. VpnQTP 1 2,885 04-09-2015, 09:07 PM
Last Post: babu123
  How to Delete Rows with duplicate values in 1 columns in excel thru QTP. arpan 0 2,849 02-09-2015, 08:47 PM
Last Post: arpan
  How to get center data value in a odd number of rows and columns web table ... sai rajesh 0 2,835 11-13-2013, 10:24 PM
Last Post: sai rajesh
  wrong code execution pkdhake 4 3,788 07-27-2013, 12:19 PM
Last Post: sreekanth chilam

Forum Jump:


Users browsing this thread: 1 Guest(s)