5

For getting Pdf report in Asp.net MVC I am working with Stimulsoft 2015. The problem is that I have no idea how to convert my code in order to work with Stimulsoft Core in Asp.net Core. it seems some features are not available anymore in Stimulsoft Core (like StiReport).

This is the code which works fine in Asp.net MVC

    public ActionResult GetReportSnapshot(string sort)
    {

        StiReport report = new StiReport();
        report.Load(Server.MapPath("~/Reports/Jobs.mrt"));

        report["@PrjectId"] = 1;
        report["@OrderBy"] = sort;
        report.Dictionary.Variables["title"] = new Stimulsoft.Report.Dictionary.StiVariable("title", sort);

        report.Render();
        MemoryStream stream = new MemoryStream();
report.ExportDocument(StiExportFormat.Pdf, stream);
        stream.Position = 0;
        FileStreamResult fsr = new FileStreamResult(stream, "application/pdf");
        return fsr;
    }

I will appreciate any help.

Elyas Esna
  • 625
  • 4
  • 19

2 Answers2

2

In NuGet Package Stimulsoft.Reports.Web.NetCore version 2018.3.5. and Asp.Net core 2.0.

This is working for me, Try this:

public IActionResult GetReportSnapshot(string sort)
        {

            StiReport report = new StiReport();
            report.Load(@"C:\Users\Admin\Desktop\report.mrt"); // laod report
            report.Render();

            report["@PrjectId"] = 1;
            report["@OrderBy"] = sort;
            report.Dictionary.Variables["title"] = new Stimulsoft.Report.Dictionary.StiVariable("title", sort);


            // Create an PDF settings instance. You can change export settings.
            var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
            // Create an PDF service instance.
            var service = new Stimulsoft.Report.Export.StiPdfExportService();

            // Create a MemoryStream object.
            var stream = new MemoryStream();
            // Export PDF using MemoryStream.
            service.ExportTo(report, stream, settings);

            return File(stream.ToArray(), "application/octet-stream");
        }
AminRostami
  • 2,585
  • 3
  • 29
  • 45
1

What nuget packages are you using? It could be you are missing the nuget packages containing the StiReport class. (I see they split up their library over multiple nuget packages)

Also it could be they have not migrated this part to dotnet core yet. i'd advise you to click around there github repo and see if you can find any information there: https://github.com/stimulsoft, or on there website.

By the looks of nuget they have only recently started to migrate to dotnet core so this would suppose my second suggestion is the right suggestion. enter image description here

Joel Harkes
  • 10,975
  • 3
  • 46
  • 65
  • I'm using stimulsoft core nuget package, and there is only one package for .net core in nuget package manager. I thought they have done with core version but it seems they are still working on it – Elyas Esna Mar 18 '17 at 14:48