如何在 asp.net mvc 中将 devexpress 报告导出为 pdf?
How to export devexpress report into pdf in asp.net mvc?
public ActionResult PrintReprtForSpecicDates(DateTime startdate, DateTime enddate)
{
string path = Server.MapPath("~/Reports/myreport.html");
ViewBag.SpecificReport = path;
using (ProDbDataContext _Context = new ProDbDataContext())
{
List<Sp_GetSpecificRecordResult> RecordList = _Context.Sp_GetSpecificRecord(startdate,enddate).ToList();
foreach (var item in RecordList)
{
item.ImagePath = "/ProductsImages/" + item.ImagePath;
}
var dt = Helper.Helper.ToDataTable(RecordList);
RptGetSpecificRecords reportobj = new RptGetSpecificRecords();
reportobj.DataSource = dt;
reportobj.Parameters["Startdate"].Value = Convert.ToDateTime(startdate).ToShortDateString();
reportobj.Parameters["Enddate"].Value = Convert.ToDateTime(enddate).ToShortDateString();
reportobj.ExportToPdf(path);
}
return View();
}
How i have to do next? i have export to html but now want to export to pdf guide me how to do next?
public ActionResult PrintReprtForSpecicDates(DateTime startdate, DateTime enddate)
{
using (ProDbDataContext _Context = new ProDbDataContext())
{
List<Sp_GetSpecificRecordResult> RecordList = _Context.Sp_GetSpecificRecord(startdate,enddate).ToList();
var dt = Helper.Helper.ToDataTable(RecordList);
RptGetSpecificRecords reportobj = new RptGetSpecificRecords();
reportobj.DataSource = dt;
reportobj.Parameters["Startdate"].Value = Convert.ToDateTime(startdate).ToShortDateString();
reportobj.Parameters["Enddate"].Value = Convert.ToDateTime(enddate).ToShortDateString();
var stream = new MemoryStream();
reportobj.ExportToPdf(stream);
return File(stream.GetBuffer(), "application/pdf");
}
}
public ActionResult PrintReprtForSpecicDates(DateTime startdate, DateTime enddate)
{
string path = Server.MapPath("~/Reports/myreport.html");
ViewBag.SpecificReport = path;
using (ProDbDataContext _Context = new ProDbDataContext())
{
List<Sp_GetSpecificRecordResult> RecordList = _Context.Sp_GetSpecificRecord(startdate,enddate).ToList();
foreach (var item in RecordList)
{
item.ImagePath = "/ProductsImages/" + item.ImagePath;
}
var dt = Helper.Helper.ToDataTable(RecordList);
RptGetSpecificRecords reportobj = new RptGetSpecificRecords();
reportobj.DataSource = dt;
reportobj.Parameters["Startdate"].Value = Convert.ToDateTime(startdate).ToShortDateString();
reportobj.Parameters["Enddate"].Value = Convert.ToDateTime(enddate).ToShortDateString();
reportobj.ExportToPdf(path);
}
return View();
}
How i have to do next? i have export to html but now want to export to pdf guide me how to do next?
public ActionResult PrintReprtForSpecicDates(DateTime startdate, DateTime enddate)
{
using (ProDbDataContext _Context = new ProDbDataContext())
{
List<Sp_GetSpecificRecordResult> RecordList = _Context.Sp_GetSpecificRecord(startdate,enddate).ToList();
var dt = Helper.Helper.ToDataTable(RecordList);
RptGetSpecificRecords reportobj = new RptGetSpecificRecords();
reportobj.DataSource = dt;
reportobj.Parameters["Startdate"].Value = Convert.ToDateTime(startdate).ToShortDateString();
reportobj.Parameters["Enddate"].Value = Convert.ToDateTime(enddate).ToShortDateString();
var stream = new MemoryStream();
reportobj.ExportToPdf(stream);
return File(stream.GetBuffer(), "application/pdf");
}
}