[]
        
在线Demo 免费试用
(Showing Draft Content)

集成报表设计器

1. 概述

1.1 功能概述

Wyn 支持将报表设计器嵌入到 Web 应用程序的任意 DIV 容器中去,为最终用户提供在线设计报表的能力。

2. 操作步骤

2.1 增加跨域设置

  1. 报表集成中除了常规的增加跨域白名单之外,还需要增加如下响应头。

    location

    content-disposition

    PixPin_2025-07-22_15-58-20

2.2 安装最新的集成包

  1. 安装最新的集成包:https://www.npmjs.com/package/@grapecity-software/wyn-integration

    npm install @grapecity-software/wyn-integration

2.3 集成

  1. 将 Wyn 报表设计器添加到 DIV 容器 wyn-root 中。

    import { WynIntegration } from "@grapecity-software/wyn-integration";
    
    let designer:any = null;
    const createDesigner = async (baseUrl, token, onSavedReport, reportId, reportType) => {
    
        if (designer) {
            designer.destroy();
            clearContainer();
        }
    
        WynIntegration.createReportDesigner({
            baseUrl: baseUrl,
            reportId: reportId, //报表文档ID
            lng: 'en',
            token: token,
            onSaved: onSavedReport,
            makeTitle: (reportName, options) => {
                const title = `${reportName}${options.dirty ? ' *' : ''}`;
                return title;
            },
        }, '#wyn-root').then(ins => {
            designer = ins;
            designer.closeViewer();
            designer.api.createReport({ reportType });
        });
    };
    
    const clearContainer = () => {
         const container = document.querySelector('#wyn-root');
         if (container) container.innerHTML = '';
    }
  • 参数说明:

    • baseURL 指 Wyn 服务器的地址。

    • token 指访问 Wyn 服务器的令牌,在 Wyn 的「系统管理>安全设置>生成令牌」界面生成,token 所代表的用户需要具有创建报表的权限。具体获取方法,请详见生成令牌

    • reportId 指报表文档 Id,可以从Wyn 的「文档门户>我的分析」中对应的报表文档列表获取。当 reportId 为空的时候,指的是创建新的报表文档。

      PixPin_2025-07-22_16-00-50

    • 更多的设置参考API文档:report

3. 资源下载

  1. 示例文件包说明: 已包含报表查看器及报表设计器两部分,您可直接导入至对应版本系统中查看使用。

    wyn-integration-vue-report.zip

    wyn-integration-react-report.zip

    注意: 本示例压缩包基于8.1版本制作,请使用8.1及以上版本并参照导入与导出文档操作(低版本可能存在兼容性问题,建议升级)。