首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向Stimulsoft内核过渡

向Stimulsoft内核过渡
EN

Stack Overflow用户
提问于 2017-03-16 15:44:52
回答 2查看 1.2K关注 0票数 5

为了在Stimulsoft中获取Asp.net报告,我使用Stimulsoft2015。问题是我不知道如何转换我的代码,以便在Asp.net核心中使用Stimulsoft核心。似乎一些功能在Stimulsoft Core (如StiReport)中不再可用。

这是在Asp.net MVC中运行良好的代码。

代码语言:javascript
复制
    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;
    }

如果有任何帮助,我将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 2017-03-16 19:11:35

您使用的是什么nuget包?可能是您缺少包含StiReport类的nuget包。(我看到他们把他们的库分成了多个nuget包)

也可能是他们还没有把这部分移植到dotnet核心上。我建议你点击那里的github repo,看看你是否可以在那里找到任何信息:https://github.com/stimulsoft,或者在那里的网站上。

从nuget的角度来看,他们最近才开始迁移到dotnet核心,所以我的第二个建议是正确的。

票数 1
EN

Stack Overflow用户

发布于 2019-07-10 19:21:45

在NuGet Package Stimulsoft.Reports.Web.NetCore 2018.3.5版本中。和Asp.Net core 2.0

这对我很有效,试试这个:

代码语言:javascript
复制
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");
        }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42828043

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档