how ASP.NET to generate excel report

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?
 
J

John

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
 
V

vinu

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
 
M

Mark Rae

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...
 
A

Alvin Bruney - ASP.NET MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top