Hi,
Is there any easy way of exporting all data from an UltraGrid programmatically? I have been toying with ...Object.Export and although QTP does not error on that line, it's not saving anything; I have tried various parameters such as filename etc as detailed in the NetAdvantage help (which is much more useful than the TestAdvantage help!) but I can't seem to quite nail it. Do you have any suggestions?
The reason I want to do this is that I have a grid that changes dynamically every time a field is changed on a form and as such there is no set number of sibling rows, and as trying to navigate an unknown number of sibling rows is proving a nightmare through QTP, I've decided to dump the grid to excel and use the Excel Object Model to do the work, which I'm much more familiar with!
Best regards, Ryan
Hi Ryan,
You need an "UltraGridExcelExporter" object to export grid content to an Excel file. Here is how its done in VS (using C#)
ExcelExporter = new Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter(); ExcelExporter.Export(ultraGrid1,"FilterRows.xls");
I'm not sure how (or even if its possible to) do this in QTP.
For the original problem, if you can explain a little more I can try to provide a code snip-it that might help you.
Regards,
Ammar
Can no-one suggest a useful code snippit for my dilemma??
Hi Ammar, thanks for the repsonse. Sorry about my delayed reply.
I think you are right, there seems no way to use the exporter in QTP, but that's not the end of the world as the AUT provides a menu option to do it anyway.
Anyhow, the reason I want to export to excel is partly bourne out of my frustration in not being able to fashion the right code in QTP to navigate through a UltraGrid reliably in the manner I want. Here is my situation: I have an Ultragrid that has many columns, and the user is allowed to group the data in the grid by whatever and however many columns they choose. They can then export their view to Excel. What I need to be able to test is that the data in Excel matches the data as displayed in the UltraGrid.
So my ultimate problem is creating some code that can navigate through all the rows of an Ultragrid, and is able to account for any number of parent/child rows. Now I know the kind of things I should be using; for example, initially doing a row count on the table, which returns the number of top level parent rows. Then going through those parent rows, querying if each one has a sibling, and so on recursively, until I get to any data rows. Sometimes there can be 5 levels of parent rows before you get to any data (but of course this can change as the data can be grouped by anything!), so of course to get data out of a cell in that row would require ...GetCellData("a;b;c;d;e;f;g", "somecolumnname"), where a-f represent the parent levels above data row 'g', so as QTP is recursively drilling down it needs to 'build up' (and remember) the path to 'g'.
I hope this explanation is clear, I'm sure it's been done before but it's proving quite tricky for me. Do you have any useful code Ammar?
Best regards,
Ryan