翻譯|使用教程|編輯:李顯亮|2021-09-06 10:36:30.620|閱讀 265 次
概述:本教程展示了在 Java 報(bào)告工具中運(yùn)行 Web 查看器的基礎(chǔ)知識(shí)。例如,在網(wǎng)頁上顯示帶有儀表板的報(bào)告。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Stimulsoft Ultimate是用于創(chuàng)建報(bào)表和儀表板的通用工具集。該產(chǎn)品包括用于WinForms、ASP.NET、.NET Core、JavaScript、WPF、PHP、Java和其他環(huán)境的完整工具集。
Stimulsoft Reports不僅擁有強(qiáng)大的報(bào)表導(dǎo)出系統(tǒng),而且還支持多種報(bào)表導(dǎo)出格式,擁有簡單且強(qiáng)大的報(bào)表引擎。Stimulsoft Reports基本原則是,用簡單常規(guī)的方法創(chuàng)建報(bào)表,將不同的技術(shù)應(yīng)用于應(yīng)用程序。Stimulsoft Reports.Java是一個(gè)專為在Java應(yīng)用程序中的報(bào)表進(jìn)行交互和處理的報(bào)表工具。
點(diǎn)擊下載Stimulsoft Reports.Java v2021.3.1最新版
本教程展示了在 Java 報(bào)告工具中運(yùn)行 Web 查看器的基礎(chǔ)知識(shí)。例如,在網(wǎng)頁上顯示帶有儀表板的報(bào)告。
首先,我們需要?jiǎng)?chuàng)建動(dòng)態(tài) Web 項(xiàng)目。
接下來將 Stimulsoft Java Lib 添加到項(xiàng)目中。
也可以轉(zhuǎn)換為 Maven 項(xiàng)目并配置“pom.xml”文件以使用來自Maven 的庫:
4.0.0webviewerwebviewer0.0.1-SNAPSHOTwarsrcmaven-compiler-plugin3.5.11.61.6com.stimulsoftstimulsoft-reports-libs2017.1.1
接下來,我們需要在“WebContent/WEB-INF”文件夾中創(chuàng)建“web.xml”文件。在這里,我們配置StimulsoftResource檢索 *.js 和圖像文件等內(nèi)容的servlet,以及StiWebViewerActionServlet與 java web 查看器一起操作的servlet :
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/webapp_2_5.xsd" xsi:schemaLocation="http://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_webviewer</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>StimulsoftAction</servlet-name> <servlet-class>com.stimulsoft.webviewer.servlet.StiWebViewerActionServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>StimulsoftAction</servlet-name> <url-pattern>/stimulsoft_webviewer_action</url-pattern> </servlet-mapping> </web-app>
在下一步中,我們需要在“WebContent”文件夾中創(chuàng)建“index.jsp”頁面。在這里,我們加載“Dashboards.mrt”報(bào)告模板文件并呈現(xiàn)報(bào)告。我們也可以配置網(wǎng)絡(luò)查看器,例如將背景顏色設(shè)置為灰色。最后,將 web 查看器標(biāo)簽放入 jsp 頁面:
<%@page import=";com.stimulsoft.base.drawing.StiColorEnum"%>
<%@page import=";com.stimulsoft.base.drawing.StiColor"%>
<%@page import=";com.stimulsoft.webviewer.StiWebViewerOptions"%>
<%@page import=";com.stimulsoft.webviewer.StiWebViewer"%>
<%@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="http://stimulsoft.com/webviewer" prefix="stiwebviewer"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Stimulsoft Reports for Java</title>
</head>
<body>
<%
StiReport report = StiSerializeManager.deserializeReport(
new File(request.getSession().getServletContext().getRealPath("/reports/Dashboards.mrt")));
report.render();
StiWebViewerOptions options = new StiWebViewerOptions();
options.getAppearance().setBackgroundColor(StiColorEnum.Gray.color());
pageContext.setAttribute("report", report);
pageContext.setAttribute("options", options);
%>
<stiwebviewer:webviewer report="${report}" options="${options}" />
</body>
</html>
現(xiàn)在您可以將項(xiàng)目部署到 Tomcat 并運(yùn)行它。
在下面的屏幕截圖中,可以看到示例代碼的結(jié)果:
Aspose、E-iceblue、FastReport、Stimulsoft等文檔/報(bào)表圖表類開發(fā)工具享超低折扣,如有需要可直接。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn