提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李显亮|2021-08-31 10:08:41.140|阅读 318 次
概述:本教程展示了在 Java 报告工具中运行 Web 设计器的基础知识。例如,打开以编辑主从报告模板。
#慧都22周年庆大促·界面/图表报表/文档/IDE/IOT/测试等千款热门软控件火热促销中>>
Stimulsoft Ultimate是用于创建报表和仪表板的通用工具集。该产品包括用于WinForms、ASP.NET、.NET Core、JavaScript、WPF、PHP、Java和其他环境的完整工具集。
Stimulsoft Reports不仅拥有强大的报表导出系统,而且还支持多种报表导出格式,拥有简单且强大的报表引擎。Stimulsoft Reports基本原则是,用简单常规的方法创建报表,将不同的技术应用于应用程序。Stimulsoft Reports.Java是一个专为在Java应用程序中的报表进行交互和处理的报表工具。
点击下载Stimulsoft Reports.Java v2021.3.1最新版
本教程展示了在 Java 报告工具中运行 Web 设计器的基础知识。例如,打开以编辑主从报告模板。
首先,我们需要创建动态 Web 项目。
然后将 Stimulsoft Java Libs 添加到项目中。
也可以转换为 Maven 项目并配置pom.xml文件以使用来自Maven 的库:
<project xmlns="//maven.apache.org/POM/4.0.0" xmlns:xsi="//www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="//maven.apache.org/POM/4.0.0 //maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>webdesigner</groupId> <artifactId>webdesigner</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.stimulsoft</groupId> <artifactId>stimulsoft-reports-libs</artifactId> <version>2017.1.1</version> </dependency> </dependencies> </project>
接下来,我们需要在“WebContent/WEB-INF”文件夹中创建“web.xml”文件。这里我们配置了StimulsoftResourceservlet 来检索诸如 *.js 和图像文件等内容,以及StiWebDesignerActionServlet与 java web 设计器一起操作的servlet :
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="//www.w3.org/2001/XMLSchema-instance" xmlns="//java.sun.com/xml/ns/javaee" xmlns:web="//java.sun.com/xml/ns/javaee/webapp_2_5.xsd" xsi:schemaLocation="//java.sun.com/xml/ns/javaee //java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>stimulsoft_webdesigner</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>StimulsoftResource</servlet-name> <servlet-class>com.stimulsoft.web.servlet.StiWebResourceServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>StimulsoftResource</servlet-name> <url-pattern>/stimulsoft_web_resource/*</url-pattern> </servlet-mapping> <servlet> <servlet-name>StimulsoftDesignerAction</servlet-name> <servlet-class>com.stimulsoft.webdesigner.servlet.StiWebDesignerActionServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>StimulsoftDesignerAction</servlet-name> <url-pattern>/stimulsoft_webdesigner_action</url-pattern> </servlet-mapping> </web-app>
在下一步中,我们需要在“WebContent”文件夹中创建“index.jsp”页面。这里我们加载“Master-Detail.mrt”报告模板文件并定义报告的数据路径:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@page import=";java.io.FileOutputStream"%>
<%@page import=";java.io.FileInputStream"%>
<%@page import=";com.stimulsoft.report.utils.data.StiDataColumnsUtil"%>
<%@page import=";com.stimulsoft.report.dictionary.StiDataColumnsCollection"%>
<%@page import=";com.stimulsoft.report.dictionary.StiDataColumn"%>
<%@page import=";com.stimulsoft.report.utils.data.StiSqlField"%>
<%@page import=";com.stimulsoft.report.dictionary.dataSources.StiDataTableSource"%>
<%@page import=";com.stimulsoft.report.utils.data.StiXmlTable"%>
<%@page import=";com.stimulsoft.report.utils.data.StiXmlTableFildsRequest"%>
<%@page import=";com.stimulsoft.webdesigner.StiWebDesigerHandler"%>
<%@page import=";com.stimulsoft.webdesigner.StiWebDesignerOptions"%>
<%@page import="com.stimulsoft.report.dictionary.databases.StiXmlDatabase"%>
<%@page import=";java.io.File"%>
<%@page import=";com.stimulsoft.report.StiSerializeManager"%>
<%@page import=";com.stimulsoft.report.StiReport"%>
<%@page language=";java" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<%@taglib uri=";//stimulsoft.com/webdesigner" prefix="stiwebdesigner"%>
<html xmlns="//www.w3.org/1999/xhtml">
<head>
<title>Stimulsoft Webdesigner for Java</title>
<style type="text/css">
</style>
</head>
<body>
<%
final String reportPath = request.getSession().getServletContext().getRealPath("/reports/Master-Detail.mrt");
final String xmlPath = request.getSession().getServletContext().getRealPath("/data/Demo.xml");
final String xsdPath = request.getSession().getServletContext().getRealPath("/data/Demo.xsd");
final String savePath = request.getSession().getServletContext().getRealPath("/save/");
...
接下来我们需要实现StiWebDesigerHandler用于填充报告数据并保存/加载报告模板:
...
StiWebDesignerOptions options = new StiWebDesignerOptions();
//options.setLocalization(request.getSession().getServletContext().getRealPath("/localization/de.xml"));
...
我们也可以指定网页设计器选项,例如设置必要的本地化:
...
StiWebDesigerHandler handler = new StiWebDesigerHandler() {
// Occurred on loading webdesinger. Must return edited StiReport
public StiReport getEditedReport(HttpServletRequest request) {
try {
StiReport report = StiSerializeManager.deserializeReport(new File(reportPath));
report.getDictionary().getDatabases().add(new StiXmlDatabase("Demo", xsdPath, xmlPath));
return report;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// Occurred on opening StiReport. Method intended for populate report data.
public void onOpenReportTemplate(StiReport report, HttpServletRequest request) {
report.getDictionary().getDatabases().add(new StiXmlDatabase("Demo", xsdPath, xmlPath));
}
// Occurred on new StiReport. Method intended for populate report data.
public void onNewReportTemplate(StiReport report, HttpServletRequest request) {
report.getDictionary().getDatabases().add(new StiXmlDatabase("Demo", xsdPath, xmlPath));
try {
StiXmlTableFildsRequest tables = StiDataColumnsUtil.parceXSDSchema(new FileInputStream(xsdPath));
for (StiXmlTable table : tables.getTables()) {
StiDataTableSource tableSource = new StiDataTableSource(
"Demo." + table.getName(), table.getName(), table.getName());
tableSource.setColumns(new StiDataColumnsCollection());
for (StiSqlField field : table.getColumns()) {
StiDataColumn column = new StiDataColumn(
field.getName(), field.getName(), field.getSystemType());
tableSource.getColumns().add(column);
}
tableSource.setDictionary(report.getDictionary());
report.getDictionary().getDataSources().add(tableSource);
}
} catch (Exception e) {
e.printStackTrace();
}
}
// Occurred on save StiReport. Method must implement saving StiReport
public void onSaveReportTemplate(StiReport report, StiRequestParams requestParams, HttpServletRequest request) {
try {
FileOutputStream fos = new FileOutputStream(savePath + requestParams.designer.fileName);
if (requestParams.designer.password != null) {
StiSerializeManager.serializeReport(report, fos, requestParams.designer.password);
} else {
StiSerializeManager.serializeReport(report, fos, true);
}
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
};
pageContext.setAttribute("handler", handler);
pageContext.setAttribute("options", options);
%>
...
最后,将网页设计器标签放到jsp页面中:
...
<stiwebdesigner:webdesigner handler="${handler}" options="${options}" />
</body>
</html>
现在您可以将项目部署到 Tomcat 并运行它。
在下面的屏幕截图中,可以看到示例代码的结果:
Aspose、E-iceblue、FastReport、Stimulsoft等文档/报表图表类开发工具享超低折扣,如有需要可直接。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@hmdbvip.cn




在现代软件开发过程中,自动化单元测试是确保代码质量与可靠性的关键环节。尤其对于特定框架(如MFC)的代码,测试复杂度显著增加,常因依赖外部资源或交互操作而难以在静默环境中顺利执行。Parasoft C/C++test作为专业的软件测试工具,致力于帮助开发团队高效实施自动化测试,通过其强大的桩函数功能,能够有效模拟依赖组件的行为,从而实现对复杂逻辑的隔离测试。
本文将为大家介绍如何在MyEclipse中使用XDoclet开发EJB 2 Session Bean,欢迎下载最新版体验!
如果能将 CSV 自动转换为 PDF ,就能快速生成清晰、美观的报表,既节省手动排版时间,又能保持数据的专业呈现。本文将介绍如何使用 Spire.XLS for Java 实现这一过程——从加载 CSV 到输出高质量 PDF,仅需数行代码即可完成。
Parasoft C/C++test是一款专为C/C++代码设计的自动化测试工具,通过静态代码分析、单元测试和运行时错误检测等功能,帮助开发团队在早期发现并修复缺陷,提升代码质量和开发效率 。在实际使用中,尤其是在VC6此类旧版开发环境中执行单元测试时,可能会因环境兼容性问题触发链接错误。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@hmdbvip.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
永利最大(官方)网站