Export web table to excel

Best practices, code snippets for common functionality, examples, and guidelines.
vivek.guvva
Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

Export web table to excel

Post by vivek.guvva » Tue Feb 23, 2016 5:11 pm

Hi,

I have data in form of a web table in my application and I need to export that into excel for validating with the database. Please let me know the way to export that web table into an excel. Any help is appreciated.

Thanks
Vivek.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Export web table to excel

Post by krstcs » Wed Feb 24, 2016 3:17 pm

I'm not sure I see how this is related to Ranorex specifically. Can you explain how you want to use Ranorex to do this?

If you are just wanting to validate the data, you should not export to Excel. Ranorex can be used, along with a data connector or straight connection to the database, to validate the values in the web table. As a matter of fact, that is what Ranorex is built for.
Shortcuts usually aren't...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3949
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Export web table to excel

Post by odklizec » Thu Feb 25, 2016 9:28 am

Hi,

There is no built-in way to write excel files. Check this post with some links discussing possibility to write Excel files...
http://www.ranorex.com/forum/how-to-rea ... tml#p35286
There are many other posts about writing to Excel. Just use search.

What could be done without the need to use 3rd party Excel libraries, is using Ranorex CSV data connector, which allows also writing CSV files. You can find a sample code (using Ranorex CSV DataConnector) here:
http://www.ranorex.com/forum/writing-in ... tml#p34657

I would also suggest you to check this code sample for advanced validation of web table:
http://www.ranorex.com/forum/how-to-rea ... tml#p35286
In this particular sample, the web table is compared with previously created reference snapshot. But I'm sure you can replace the snapshot with data obtained form database. It would just require some more coding ;) I think this particular code could help as well:
http://www.ranorex.com/support/user-gui ... html#c7787
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

vivek.guvva
Posts: 31
Joined: Mon Feb 22, 2016 7:21 pm

Re: Export web table to excel

Post by vivek.guvva » Thu Feb 25, 2016 5:12 pm

Let me explain in more detail

I have a table in a web application and I need to compare those values with the database. I thought of exporting the table from web application to excel and then comparing the data in excel with database. Please let me know if there is any other easy way to do that.

Thanks
Vivek

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Export web table to excel

Post by krstcs » Thu Feb 25, 2016 7:16 pm

As I said, you should just use the Ranorex Validate class on the table directly, using the database data as your expected result. There is no need to export to CSV/XLS.

1. Create a module that validates the data for a given row, column, and data value.
2. Create a Test Case in your suite in the spot where you need to validate the data.
3. Create a SQL Data Connector for the new Test Case using a SQL Query that gets the expected row/column/value information.
4. Bind the module variables to the data connector values.
5. Run the test.

The new test case will loop over each row in the SQL query and pass that info to the module, which would validate that the information in the table is the same.
Shortcuts usually aren't...