【问题标题】:JSReport Generation in Web apiWeb api 中的 JSReport 生成
【发布时间】:2016-05-05 03:31:42
【问题描述】:

我有两个不同的 web api 项目。

一个充当“API”,一个充当“使用 angularjs 的前端”。

如何在我的项目中实现 jsreport?

是否可以通过从另一个api项目中获取数据来使用angularjs在web api前端实现jsreport?

请帮助我找到正确的解决方案。

因为我看到jsreport非常适合生成pdf格式的前端报告。

我正在使用 Microsoft Visual Studio Professional 2013。

提前致谢。

【问题讨论】:

    标签: jsreport


    【解决方案1】:

    最简单的方法是使用可通过 NuGet 获得的 JsReport .NET 集成,并使用您的 Web API 使用的服务方法为后端对 JsReport 的请求生成数据。 documentation 相当不错。

    【讨论】:

      【解决方案2】:

      是的,您可以使用 Web API 作为报告的数据提供者并生成报告。您可以从here 获取有关 Jsreport 入门的文章。

      【讨论】:

        【解决方案3】:

        这里是您如何使用 api 在您的 Angular 应用程序中生成 JSReport

        app.controller('mainCtrl' , function($scope, $http){
          $scope.yourData = {
          //your data goes here
          }
            var settings = {
              "async": true,
              "crossDomain": true,
              "url": "http://localhost:3001/api/report",
              "method": "POST",
              "headers":{
                "content-type": "application/json",
                "cache-control": "no-cache"
              },
              "processData": false,
              "data": {"template": { "shortid" : "short-id-of-your-template", "recipe": 'html'},"data": yourData
              }
              }
            }
            $http(settings).then(function(responce){     
                      $scope.htmlresponce = responce.data
                      console.log(responce.data)//your html of jsreport will go here
            })
          }
        
        })

        将“short-id-of-your-template”替换为您的模板 shortId

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-08-20
          • 2015-05-25
          • 1970-01-01
          • 2017-10-15
          • 1970-01-01
          • 1970-01-01
          • 2018-09-29
          • 1970-01-01
          相关资源
          最近更新 更多