I need to download an excel file from a site. I created a WebBrowser control inside a Windows Form that navigates to the site, select a criteria, clicks a search button which opens up another page.
Now on this page there is a link button with a javascript function, that downloads an excel file when it is clicked.
the link code is the following:
<a onclick="$find('ReportViewer').exportReport('Excel');" href="javascript:void(0)" style="color: rgb(51, 102, 204); font-family: Verdana; font-size: 8pt; padding: 3px 8px 3px 32px; display: block; white-space: nowrap; text-decoration: none;">Excel</a>
I wrote a code in the WebBrowser to find the link with Text "Excel" and click it, but this opens up Internet explorer and prompts the user for download. This is an automated process, so I don't need the prompt, I need the download to happen automatically and save the file in a specific directory.
I tried to use this solution
Download a file through the WebBrowser control
But it doesn't work in my case, I think because I don't have a direct url that ends with pdf or xls. It's a javascript call.
Any ideas ?