Extract Data from a Web Page into an Excel Spreadsheet Using ASP.Net Application and
Excel file save Automaticaly in our Application.Following are detail what i wanti Create a web application in that application their are some link when we click on that link and redirect on contact page the contact details are store automaticaly in excel
Extract Data from a Web Page into an Excel Spreadsheet Using ASP.Net Application and
Excel file save Automaticaly in our Application
Eugene MontesPosted Mar 19, 2015, 4:01 AM
Now the main thing here is the "Page.RenderControl(hw)" call which will retrieve the actual HTML representation of some web control (in this case the Page), but in order to successfully call this method you need override the "VerifyRenderingInServerForm", like the following:
public override void VerifyRenderingInServerForm(Control control) { }
And also you need to disable "EnableEventValidation" on the Page, like the following:
<%@ Page EnableEventValidation="false" ...
In case you need a real excel file then you will have to use some other approach, note that you can find some .NET libraries that can help you out with this.
For example you can try out this Excel library for .NET, it can convert the HTML content into an excel file in .NET and then you can export that excel file in ASP.NET.
Vishnu BhangalePosted Mar 17, 2015, 6:15 AM
You are correct but when i call it on page load the blank excel will generate please give me full code.
Rahul BansalPosted Mar 17, 2015, 6:14 AM
http://www.c-sharpcorner.com/UploadFile/ankurmalik123/export-html-to-excel-and-more/
Rahul BansalPosted Mar 17, 2015, 6:03 AM
I will try to extract the other website to excel.
Vishnu BhangalePosted Mar 17, 2015, 5:57 AM
Your code is only open blank excel file
Vishnu BhangalePosted Mar 17, 2015, 5:53 AM
My Question is not to upload the excel file in application my question is to store the web page content in excel file using .net and this will be done when i click on any other link that are in my application ex.suppose i click on google.com then google page will open and the content of google page will save in excel this will be done automaticaly after i click on link.
Rahul BansalPosted Mar 17, 2015, 5:46 AM
using System.IO;
public void expgrid()
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=RepeaterExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Page.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}