how ASP.NET to generate excel report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how ASP.NET to generate excel report(office 2003) to client
what component i need to reference into the asp.net application
and what component i need to install to the server?

Moreover, does it free?
 
ken said:
how ASP.NET to generate excel report(office 2003) to client
what component i need to reference into the asp.net application
and what component i need to install to the server?

Moreover, does it free?

Hi Ken,

I don't know how much control you need, but I just generate a csv file for
the user. The user is then asked to save or open the file with the default
app (ussually Excel).

This ussually works enough that I can keep it as simple as possible. I also
generate a tocsv.aspx file, so it's generic.

Good luck,
John
 
Ken

Create a crystal report and export the content as Excel, that's the cheapest
way
see the sample code..

ReportDocument r=new ReportDocument();
crTableLogOnInfo=new TableLogOnInfo();

rptFiles=(MapPath("Reports\\xxx.rpt"));

r.Load(rptFiles);
crDatabase=r.Database;
for (int i = 0; i < crDatabase.Tables.Count; i++)
{
crTable = crDatabase.Tables;
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);

}


s=(System.IO.MemoryStream) r.ExportToStream(ExportFormatType.Excel);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/x-msexcel";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;
filename=Report.xls");
HttpContext.Current.Response.BinaryWrite(s.ToArray());
HttpContext.Current.Response.End();
r.Close();

Hope this help you...

vinu
 
I don't know how much control you need, but I just generate a csv file for
the user. The user is then asked to save or open the file with the
default app (ussually Excel).

Alternatively, if you want some more "presentation" formatting, create an
HTML document and then change its extension to .xls. Excel will just
"understand" what to do with it...
 
Your easiest cheapest bet is to change the content type to excel and
response.write the content out. it will appear in the browser as a
spreadsheet. If you want more, you'll need to use a third party product.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
Back
Top