none
ASP.NET MVC modeldeki verileri yazdırma hk. RRS feed

Yanıtlar

  • RDLC Kullan derim.

    Önce Report.rdlc oluştur, sonra dataset oluştur daha sonra Controller da bir method oluştur.

    Örneğin;

    public ActionResult ExportPdf()
            {
                    string id = "PDF";
                    LocalReport lr = new LocalReport();
                    string path = Path.Combine(Server.MapPath("~/Report"), "Report_TotalKullanici.rdlc");
                    if (System.IO.File.Exists(path))
                    {
                        lr.ReportPath = path;
                    }
                    else
                    {
                        return RedirectToAction("Index", "Kullanici");
                    }
    
    
                    var cm = db.Kullanici.ToList().OrderBy(d => d.Ad);
    
    
                    ReportDataSource rd = new ReportDataSource("DataSet_TotalKullanici", cm);
                    lr.DataSources.Add(rd);
                    string reportType = id;
                    string mimeType;
                    string encoding;
                    string fileNameExtension;
    
    
    
                    string deviceInfo =
    
                        "<DeviceInfo>" +
                        "  <OutputFormat>" + id + "</OutputFormat>" +
                        "  <PageWidth>16.54in</PageWidth>" +
                        "  <PageHeight>11.69in</PageHeight>" +
                        "  <MarginTop>0.5in</MarginTop>" +
                        "  <MarginLeft>1in</MarginLeft>" +
                        "  <MarginRight>1in</MarginRight>" +
                        "  <MarginBottom>0.5in</MarginBottom>" +
                        "</DeviceInfo>";
    
                    Warning[] warnings;
                    string[] streams;
                    byte[] renderedBytes;
    
                    renderedBytes = lr.Render(
                        reportType,
                        deviceInfo,
                        out mimeType,
                        out encoding,
                        out fileNameExtension,
                        out streams,
                        out warnings);
                    return File(renderedBytes, mimeType);
    
                
            }
    Bunu inceleyebilirsin  https://www.youtube.com/watch?v=2q42e7UGssc


    18 Ocak 2018 Perşembe 08:14