Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add a row to a datatable
#1
Solved: 11 Years, 4 Months ago
Hi!

I need to create a performance log while running qtp tests, and I want to write the results out to an excel sheet.

Now, there does not seem to be an obvious way to create a row in excel. Even more so, using datatable.nextRow will jump to the freaking first row, and what makes it even worse is that if I used a pre-prepared sheet with dummy values in it, "lastRow" will take me to the last row of those dummy values (obviously), so before each write to the excel I would need to actually search for the first entry which is a dummy value, before I could write to the sheet.

Can somebody please help me out!? (Or if there is no way of adding a row let me know the adress of the guy who designed that freaking qtp object model?)

Thanks alot!

Cheers,
CC
Reply
#2
Solved: 11 Years, 4 Months ago
Quote:(Or if there is no way of adding a row let me know the adress of the guy who designed that freaking qtp object model?)

LOL Smile

ok, this has to do with excel automation model rather than QTP's automation model. You can write a custom function that opens an external excel workbook , opens a sheet in it and then add the required message in the required cell.

I am providing a function, i wrote sometime back for a similar requirement...hope it will help you get started. You can improvise upon it as per your needs.

Code:
Function PutValueInFile (sfilePath, msg, irow, icolumn,isheet)
   sfilePath = "C:\Test.xls"
   Set ExcelObj = CreateObject("Excel.Application")
   ExcelObj.Workbooks.Open sfilePath
   Set NewSheet = ExcelObj.Sheets.Item(isheet)
   NewSheet.Cells(irow,icolumn) = msg
   ExcelObj.ActiveWorkbook.Save
   ExcelObj.Application.Quit
   Set ExcelObj = Nothing
End Function
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 11 Years, 4 Months ago
Yeah!

Smile
Thanks so much mate!

I think the QTP people should forget about their internal libraries and instead promote only using that excel object model..

I assume I might be able to format result-sheets with that as well???


THanks again!

Cheers!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  DataGrid: double click on selected row robertosalemi 0 4,437 05-12-2016, 03:00 PM
Last Post: robertosalemi
  Row count is always shown as 1 Harry1999 0 2,093 04-14-2016, 11:11 PM
Last Post: Harry1999
  AddParameter method does not add in first column of datatable alpha1 4 5,588 07-14-2015, 12:44 AM
Last Post: supputuri
  Keep row number imbizile 0 2,756 09-18-2014, 03:31 AM
Last Post: imbizile
  Retrieve row number based on value in DataTable marfa 6 30,778 07-31-2014, 08:36 PM
Last Post: dharshinishankari@gmail.com

Forum Jump:


Users browsing this thread: 1 Guest(s)