1
I intend to generate some reports in my application and I am using Crystal Reports. The Report itself is correct but I can’t load it on my page (.aspx).
Follow the Load event code of my application:
protected void Page_Load(object sender, EventArgs e)
{
var doc = new ReportDocument();
doc.Load(MapPath("~/Relatorios/MeuRelatorio.rpt"));
doc.SetDatabaseLogon("my_user","senha123");
this.CrystalReportViewer1.ReportSource = doc;
this.CrystalReportViewer1.PrintMode = PrintMode.Pdf;
this.CrystalReportViewer1.RefreshReport();
}
The code does not show anything on the page, but debugging I was able to see all the results inserted in the variable doc. I could see your lines, login success result and etc.
I know that in MVC I can give a Return in Action with the guy File, and in the File i export the report result, example:
public ActionResult Relatorio()
{
//Restante do código
//Exporta em pdf à variável "stream"
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
rptH.Refresh();
//Retorna o tipo File
return File(stream, "application/pdf");
}
But in Web Forms I have no idea how to extract this information on the screen.
Thank you @Cigano! You did not solve, but gave a light. The solution is published.
– Matheus Bessa