This is a migrated thread and some comments may be shown as answers.

[Solved] Export to excel sheet

1 Answer 43 Views
Automation Design Canvas
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Archana Sathyanarayan
Top achievements
Rank 1
Archana Sathyanarayan asked on 20 Nov 2009, 12:46 PM

Hi:

How do I export  the content of a table to an excel sheet.  For example, the table in the screenshot attached below need to be exported to an excel sheet.  The table is dynamic, whenever the user inserts a record the table grows. Irrespective of the table size, I want to export the table contents into an excel sheet

 


Regards
Archana  

1 Answer, 1 is accepted

Sort by
0
Missing User
answered on 20 Nov 2009, 04:51 PM
Hello Archana,

So is the table an html table or a Rad type control like a Grid? If it is an html table, you can do something like the following in a code behind file based on this online example:

Highlight the entire table, right click, then in the context menu click 'Add to Project Elements'. The table at the top of the example page (Apples 44%, Bananas 23%...) is added to the project and in the Elements Window as 'table_8'.

Then in a code behind file you can add code like the following:

[CodedStep("Parse Table")]
 public void ParseTableStep()
 {
     String s;
     HtmlTable t = Pages.HTML_Tables.table_8; //table_8 is example table
     foreach(HtmlTableRow r in t.Rows)
          foreach(HtmlTableCell c in r.Cells)
             s = c.TextContent;
 }

String s is the data from the table that you would use to export to a spread sheet. Based on the screen shot you sent, it seems you would have to add further logic to ignore values you do not want. If rows are dynamically added to the table, be sure to add an ActiveBrowser.RefreshDomTree() after the row insertion to get the latest dom to use for parsing the table.

If the table is a Rad Grid or some other Rad type control, I believe you can probably do something similar in code. If this is indeed the case, please post back and I think Konstantin would be able to help you out better in this respect.

Exporting the data to an Excel spreadsheet is something WebUI does not support out of the box. You would have to write your own implementation for doing this in the code behind file of your WebUI test.

All the best,
Nelson Sin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Automation Design Canvas
Asked by
Archana Sathyanarayan
Top achievements
Rank 1
Answers by
Missing User
Share this question
or