displaying report in excel
-
how to display the crystel report in excel. i want to show the dataset in ms excel.by using c#
-
how to display the crystel report in excel. i want to show the dataset in ms excel.by using c#
You can use the below written procedure to display the crystal report in excel format in a web form. You have to pass the instance of the crystal report and the dataset as parameter to this procedure.
private void subDisplayReport(ReportClass rptObject, DataSet lDataSet)
{
rptObject.SetDataSource(lDataSet);
rptObject.ExportOptions.FormatOptions = new ExcelFormatOptions();
rptObject.ExportOptions.ExportFormatType = ExportFormatType.Excel;
ExportRequestContext req = new ExportRequestContext();
req.ExportInfo = rptObject.ExportOptions;
System.IO.Stream st;
st = rptObject.FormatEngine.ExportToStream(req);
byte[] b = new byte[(int)st.Length + 1];
st.Read(b, 0, (int)st.Length);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/xls";
Response.AddHeader("content-disposition", "inline; filename=MyReport.xls");
Response.BinaryWrite(b);
Response.End();
}Procedure written by John(J O N) in VB.NET on 19/10/2005. Code converted to C#
- Regards -
JON
Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
-
how to display the crystel report in excel. i want to show the dataset in ms excel.by using c#
What does this have to do with ASP.NET?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon