如何在ember应用程序中添加stimulsoft report.js

时间:2016-04-07 08:20:17

标签: ember.js stimulsoft

我有一个Ember应用程序,我想从Stimulsoft Reports.js中添加一些功能

我尝试将原生js文件添加到我的ember应用程序中,但它重新定义了Ember使用的Promise对象。结果我遇到了运行时错误。

然后我找到了node.js(https://www.npmjs.com/package/stimulsoft-reports-js)的npm包,并使用ember-browserify包包含它,但是我遇到了构建错误:无法从'D:..找到模块'./path' \ node_modules \ stimulsoft-报告-JS'

的package.json:

{
  "name": "ember-app",
  "version": "0.0.0",
  "description": "Small description for ember-app goes here",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "build": "ember build",
    "start": "ember server",
    "test": "ember test"
  },
  "repository": "",
  "engines": {
    "node": ">= 0.10.0"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "broccoli-asset-rev": "^2.2.0",
    "ember-ajax": "0.7.1",
    "ember-browserify": "^1.1.8",
    "ember-cli": "2.3.0",
    "ember-cli-app-version": "^1.0.0",
    "ember-cli-babel": "^5.1.5",
    "ember-cli-cordova": "0.0.19",
    "ember-cli-dependency-checker": "^1.2.0",
    "ember-cli-htmlbars": "^1.0.1",
    "ember-cli-htmlbars-inline-precompile": "^0.3.1",
    "ember-cli-inject-live-reload": "^1.3.1",
    "ember-cli-moment-shim": "1.1.0",
    "ember-cli-qunit": "^1.2.1",
    "ember-cli-release": "0.2.8",
    "ember-cli-sass": "5.3.0",
    "ember-cli-sri": "^2.0.0",
    "ember-cli-uglify": "^1.2.0",
    "ember-data": "^2.3.0",
    "ember-disable-proxy-controllers": "^1.0.1",
    "ember-export-application-global": "^1.0.4",
    "ember-flexberry": "git+https://github.com/Flexberry/ember-flexberry.git#7eff906fb53b296d689d00c34a3105d093195467",
    "ember-flexberry-offline": "git+https://github.com/Flexberry/ember-flexberry-offline.git#05ade1817c01ce4d0d578231c6ef468b7c98b30f",
    "ember-load-initializers": "^0.5.0",
    "ember-localforage-adapter": "git+https://github.com/Flexberry/ember-localforage-adapter.git#3781ba0742190c7c880a209175903d437cec0a8f",
    "ember-moment": "6.0.0",
    "ember-resolver": "^2.0.3",
    "ember-simple-auth": "1.0.1",
    "loader.js": "^4.0.0",
    "opentype.js": "^0.6.2",
    "semantic-ui-ember": "0.9.3",
    "stimulsoft-reports-js": "^2016.1.5",
    "strip-bom": "^2.0.0"
  },
  "dependencies": {}
}

component.js:

import Ember from 'ember';
import fs from 'npm:fs';
import stripBom from 'npm:strip-bom';
import opentype from 'npm:opentype.js';
import ReportJS from 'npm:stimulsoft-reports-js';

export default Ember.Component.extend({

    didInsertElement() {
        var Stimulsoft = ReportJS.Stimulsoft;
        console.log("Stimulsoft Reports loaded");

        var font = opentype.loadSync('node_modules/stimulsoft-reports-js/demo-files/Roboto-Black.ttf');
        Stimulsoft.Base.StiFontCollection.addOpentypeFont(font);
        console.log("Font loaded");

        // Creating new report
        var report = new Stimulsoft.Report.StiReport();
        console.log("New report created");

        // Loading report template
        var reportTemplate = fs.readFileSync('node_modules/stimulsoft-reports-js/demo-files/SimpleList.mrt', "utf8");
        report.load(reportTemplate);
        console.log("Report template loaded");

        // Loading demo data
        var demoData = stripBom(fs.readFileSync('node_modules/stimulsoft-reports-js/demo-files/Demo.json', "utf8"));
        report.dictionary.databases.clear();
        report.regData("Demo", "Demo", demoData);
        console.log("Demo data loaded into the report. Tables count: ", report.dataStore.count);

        var viewer = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false); 
        viewer.report = report; 
        viewer.renderHtml("reportViewer");      
    }
});

1 个答案:

答案 0 :(得分:0)

问题解决了。

刺激成分中的错误