หลังจากผ่านการโหลด Report (file .rpt) แล้ว set Parameter เรียบร้อยก็ไม่มีปัญหาอะไรเกิดขึ้น
แต่พอจะ Export to Stream ดันฟ้อง "The system cannot find the path specified. " ซะงั้น
มึนตึ๊บเลย ....
var fileName = string.Format("{0}_{1}.{2}", model.ReportName.Replace(" ", "_"), DateTime.Now.ToString("yyMMddhhmmss"), "pdf");
ReportDocument report = new ReportDocument();
var rptname = "D:\\Report\\" + report_name.rpt;
report.Load(rptname);
report.SetDatabaseLogon("sa", "1234");
var name = "Key";
var value = "Value";
report.SetParameterValue(name, value);
try
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ClearHeaders();
Stream output = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
output.Seek(0, SeekOrigin.Begin);
return File(output, "application/pdf", fileName);
}
catch (Exception ex)
{
message = ex.Message;
}
มีใครเคยเจอปัญหา "The system cannot find the path specified. " บ้างไหม... เเล้วควรจะแก้ยังไง?
แต่พอจะ Export to Stream ดันฟ้อง "The system cannot find the path specified. " ซะงั้น
มึนตึ๊บเลย ....
var fileName = string.Format("{0}_{1}.{2}", model.ReportName.Replace(" ", "_"), DateTime.Now.ToString("yyMMddhhmmss"), "pdf");
ReportDocument report = new ReportDocument();
var rptname = "D:\\Report\\" + report_name.rpt;
report.Load(rptname);
report.SetDatabaseLogon("sa", "1234");
var name = "Key";
var value = "Value";
report.SetParameterValue(name, value);
try
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ClearHeaders();
Stream output = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
output.Seek(0, SeekOrigin.Begin);
return File(output, "application/pdf", fileName);
}
catch (Exception ex)
{
message = ex.Message;
}