Stimulsoft 不适用于列表数据

Stimulsoft not work with list Data

我在 Stimulsoft 中编写了制作报告的函数

 public ActionResult Report2()
    {
        Stimulsoft.Report.StiReport rpt = new Stimulsoft.Report.StiReport();
        using (var dbase = new Entities())
        {
            var myCity = dbase.Pub_City.ToList();
            rpt.Load(Server.MapPath("\report\city.mrt"));
            rpt.RegData("myCity", myCity);

            if (rpt.RenderedPages.Count == 0)
            {
                rpt.Render(new Stimulsoft.Report.Engine.StiRenderState(true));
            }
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                rpt.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, ms, settings);
                return File(ms.GetBuffer(), "application/pdf");
            }
        }
    }

    public Stimulsoft.Report.Export.StiPdfExportSettings settings
    {
        get
        {
            Stimulsoft.Report.Export.StiPdfExportSettings _s =
                new Stimulsoft.Report.Export.StiPdfExportSettings
                {
                    EmbeddedFonts = true,
                    UseUnicode = true,
                    ImageResolution = 300
                };
            return _s;
        }
        set { }
    }

但是当从数据库中获取数据并传递给 stimulsoft 时,我没有任何响应,最后我收到超时错误

我的错误是什么?

  • 将您的 dbase.Pub_City.ToList() 移动到一个单独的函数,然后在此处使用它。不要对整个块使用它的 using 语句。
  • RegData 接受 DataTable。使用 RegBusinessObject 传递列表。
  • 也不要使用ms.GetBuffer(),因为它比原始数据大并且包含垃圾。请尝试 ms.ToArray()
  • 您只需一行即可替换整个导出部分:return StiMvcViewer.ExportReportResult(this.HttpContext);