diff --git a/.github/workflows/Release-Please.yml b/.github/workflows/Release-Please.yml
index f7c82a0..0d96b93 100644
--- a/.github/workflows/Release-Please.yml
+++ b/.github/workflows/Release-Please.yml
@@ -2,7 +2,7 @@ on:
workflow_dispatch:
push:
branches:
- - 'main'
+ - 'master'
# https://github.com/OWNER/REPO/settings/actions
# MUST CHANGE GITHUB_TOKEN PERMISSION FROM READ TO WRITE
diff --git a/.gitignore b/.gitignore
index 79dad5f..1dad5eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,5 @@ buildNumber.properties
### spring-boot ###
application-prod.properties
+
+reports
\ No newline at end of file
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index ca5ab4b..b27a13f 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1,18 +1,2 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
-wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 5693c87..e9dda59 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -15,5 +15,11 @@
"internal-terms": false // Disable the `internal-terms` dictionary
},
"auto-header-plus.pathContainsWorkspaceFolder": false,
- "java.debug.settings.onBuildFailureProceed": true
+ "java.debug.settings.onBuildFailureProceed": true,
+ "auto-header-plus.commentElementsValue": {
+ "CopyRight": "Dedienne Aerospace China ZhuHai"
+ },
+ "auto-header-plus.style.0": {
+ "lineWidth": 120
+ }
}
diff --git a/README.md b/README.md
index f9f7bae..1526813 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ An Crystal Report server run in java.
### Linux System Prepare
-1. Copy fonts to`JAVA_HOME/lib/fonts`, and set permission to this folder。
+1. Copy fonts to`$JAVA_HOME/lib/fonts`, and set permission to this folder。
```
sudo chmod -R $JAVA_HOME/lib/fonts 755
```
@@ -34,10 +34,10 @@ An Crystal Report server run in java.
2. Config your database url, driverClassName, user, password in `application.properties`.
3. Run `maven package` to get `war` package.
4. Copy `war` to tomcat, copy crystal dependency `lib` files to `WEB-INF/lib` folder, and run tomcat.
-5. Then copy your crystal report files to `WEB-INF/reports` folder, you can add them at anytime.
+5. Then copy your crystal report files to `WEB-INF/class/reports` folder, you can add them at anytime.
6. Open `http://server:port/Report/{ReportTemplateName}/{format}?param0=val0¶m1=val1` in browser, you can see your report.
7. If chinese text can't display in pdf, please configure /ect/locale.conf `LANG=zh_CN.UTF-8`
> Note: `{ReportTemplateName}` is the name of your report template file without extension, `{format}` is the format you want, such as `pdf` `doc` `xls`, `param0` and `param1` are the parameters of your report, give a param named with `filename`, this param value will be used as the file name.
> Suggestion: Using `Command SQL` instead of `Table Link` for better performance, reduce the report generation duration.
-> Suggestion: Set Tomcat JNI for better performance, reduce the report generation duration.
+
diff --git a/README.zh-cn.md b/README.zh-cn.md
index ccda5a7..d0cde7a 100644
--- a/README.zh-cn.md
+++ b/README.zh-cn.md
@@ -12,7 +12,7 @@
### Linux 系统环境准备
-1. 将需要到字体复制到`JAVA_HOME/lib/fonts`目录中, 并设置好权限。
+1. 将需要到字体复制到`$JAVA_HOME/lib/fonts`目录中, 并设置好权限。
```
sudo chmod -R $JAVA_HOME/lib/fonts 755
```
@@ -34,10 +34,10 @@
2. 在 `application.properties` 中配置数据库连接信息。
3. 运行 `maven package` 生成 `war` 包,将 `war` 包拷贝到 tomcat(或者其他容器) 中运行, `war`包是为了更新报表更便捷。
4. 将依赖库`lib`文件拷贝到`WEB-INF/lib` 文件夹中。
-5. 将水晶报表`rpt`文件拷贝到 `WEB-INF/reports` 文件夹中,可以随时添加。
+5. 将水晶报表`rpt`文件拷贝到 `WEB-INF/class/reports` 文件夹中,可以随时添加。
6. 在浏览器中打开 `http://server:port/Report/{ReportTemplateName}/{format}?param0=val0¶m1=val1`,即可看到报表。
7. 如果 pdf 文件不能显示中文, 请编辑/ect/locale.conf `LANG=zh_CN.UTF-8`
> 说明:`{ReportTemplateName}` 是报表模板文件名,不包含扩展名;`{format}` 是报表格式,如 `pdf` `doc` `xls`;`param0` 和 `param1` 是报表参数,如果有一个参数名包含 `filename`,则该参数值将作为文件名。
> 建议:使用`Command SQL`代替`Table Link`,可以获得更快的报表生成速度。
-> 建议:配置 Tomcat JNDI 数据库连接池,可以获得更快到报表生成速度。
+
diff --git a/lib/CrystalCommon2.jar b/lib/CrystalCommon2.jar
index 650b7db..6701578 100644
Binary files a/lib/CrystalCommon2.jar and b/lib/CrystalCommon2.jar differ
diff --git a/lib/CrystalReportsRuntime.jar b/lib/CrystalReportsRuntime.jar
index 92dbb18..a3b8290 100644
Binary files a/lib/CrystalReportsRuntime.jar and b/lib/CrystalReportsRuntime.jar differ
diff --git a/lib/DatabaseConnectors.jar b/lib/DatabaseConnectors.jar
index 2811da3..540c62e 100644
Binary files a/lib/DatabaseConnectors.jar and b/lib/DatabaseConnectors.jar differ
diff --git a/lib/JDBInterface.jar b/lib/JDBInterface.jar
index cdf257e..b8ccae1 100644
Binary files a/lib/JDBInterface.jar and b/lib/JDBInterface.jar differ
diff --git a/lib/QueryBuilder.jar b/lib/QueryBuilder.jar
index 8afc450..448aef0 100644
Binary files a/lib/QueryBuilder.jar and b/lib/QueryBuilder.jar differ
diff --git a/lib/cvom.jar b/lib/cvom.jar
index 6e94015..b70e2d9 100644
Binary files a/lib/cvom.jar and b/lib/cvom.jar differ
diff --git a/lib/jrcerom.jar b/lib/jrcerom.jar
index f005ed6..28d525b 100644
Binary files a/lib/jrcerom.jar and b/lib/jrcerom.jar differ
diff --git a/lib/logging.jar b/lib/logging.jar
index ce7278a..1526c05 100644
Binary files a/lib/logging.jar and b/lib/logging.jar differ
diff --git a/lib/pfjgraphics.jar b/lib/pfjgraphics.jar
index c367314..9436364 100644
Binary files a/lib/pfjgraphics.jar and b/lib/pfjgraphics.jar differ
diff --git a/pom.xml b/pom.xml
index 9a86aca..1c5d0ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,8 +4,9 @@
org.springframework.boot
spring-boot-starter-parent
- 3.1.3
-
+ 3.1.4
+
+
com.da
@@ -49,7 +50,7 @@
-
+
org.springframework.boot
spring-boot-configuration-processor
@@ -281,9 +282,16 @@
org.apache.maven.plugins
maven-war-plugin
- 3.3.2
+ 3.4.0
+
+ ${pom.basedir}/lib
+
+ *.jar
+
+ WEB-INF/lib
+
diff --git a/reports/TEST.rpt b/reports/TEST.rpt
index 6579a37..21fb835 100644
Binary files a/reports/TEST.rpt and b/reports/TEST.rpt differ
diff --git a/src/main/java/com/da/crystal/report/CRJavaHelper.java b/src/main/java/com/da/crystal/report/CRJavaHelper.java
index 5edaa83..ac87046 100644
--- a/src/main/java/com/da/crystal/report/CRJavaHelper.java
+++ b/src/main/java/com/da/crystal/report/CRJavaHelper.java
@@ -1,11 +1,11 @@
-/*********************************************************************************************************************
- * @Author : Robert Huang<56649783@qq.com> *
- * @CreatedDate : 2023-03-07 00:03:27 *
- * @LastEditors : Robert Huang<56649783@qq.com> *
- * @LastEditDate : 2023-06-28 13:00:08 *
- * @FilePath : src/main/java/com/da/crystal/report/CRJavaHelper.java *
- * @CopyRight : Dedienne Aerospace China ZhuHai *
- ********************************************************************************************************************/
+/**********************************************************************************************************************
+ * @Author : Robert Huang<56649783@qq.com> *
+ * @CreatedDate : 2023-03-07 00:03:27 *
+ * @LastEditors : Robert Huang<56649783@qq.com> *
+ * @LastEditDate : 2023-10-19 16:38:07 *
+ * @FilePath : src/main/java/com/da/crystal/report/CRJavaHelper.java *
+ * @CopyRight : Dedienne Aerospace China ZhuHai *
+ *********************************************************************************************************************/
/**
* This sample code is an example of how to use the Business Objects APIs.
@@ -82,7 +82,8 @@ public static void logonDataSource(ReportClientDocument clientDoc, String userna
/**
* Changes the DataSource for all table, include sub reports also.
- * ⚠️Suggest setup JNDI for best performance⚠️
+ * If it doesn't need to change the DataSource, it will do logon directly,
+ * If changed the DataSource, it will save the datasource to the report
* ⚠️Suggest using Command sql instead of tables⚠️
*
* @param clientDoc The reportClientDocument representing the report being used
@@ -90,9 +91,12 @@ public static void logonDataSource(ReportClientDocument clientDoc, String userna
* @param password The DB logon password
* @param connectionURL The connection URL
* @param driverName The driver Name
- * @param jndiName The JNDI name, without "jdbc/", but you need set: *
- * @CreatedDate : 2023-03-06 21:22:42 *
- * @LastEditors : Robert Huang<56649783@qq.com> *
- * @LastEditDate : 2023-09-11 22:09:04 *
- * @FilePath : src/main/java/com/da/crystal/report/ReportController.java *
- * @CopyRight : Dedienne Aerospace China ZhuHai *
- ********************************************************************************************************************/
+/**********************************************************************************************************************
+ * @Author : Robert Huang<56649783@qq.com> *
+ * @CreatedDate : 2023-03-06 21:22:42 *
+ * @LastEditors : Robert Huang<56649783@qq.com> *
+ * @LastEditDate : 2023-10-19 16:46:17 *
+ * @FilePath : src/main/java/com/da/crystal/report/ReportController.java *
+ * @CopyRight : Dedienne Aerospace China ZhuHai *
+ *********************************************************************************************************************/
package com.da.crystal.report;
@@ -65,7 +65,7 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp)
if (log.isDebugEnabled()) {
log.debug("Report: " + report + " Format: " + format);
}
- // Check format
+ // Check format, it doesn't list all formats supported by Crystal Reports, just listed we want
List allowedFormat = Arrays.asList("pdf", "xls", "doc", "rtf", "csv");
if (!allowedFormat.contains(format)) {
resp.getWriter().write("Document format {" + format + "} is not supported!
");
@@ -73,8 +73,7 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp)
}
// Check report template file
- String reportsPath =
- Thread.currentThread().getContextClassLoader().getResource("").getPath() + "reports/";
+ String reportsPath = Thread.currentThread().getContextClassLoader().getResource("").getPath() + "reports/";
log.debug(reportsPath);
File file = new File(reportsPath + report + ".rpt");
if (!file.exists()) {
@@ -88,7 +87,9 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp)
var reqParams = req.getParameterMap();
for (String key : reqParams.keySet()) {
String value = reqParams.get(key)[0];
- log.debug("Request Parameter: {} ; Value: {}", key, value);
+ if (log.isDebugEnabled()) {
+ log.debug("Request Parameter: {} ; Value: {}", key, value);
+ }
if (key.toUpperCase().equals("FILENAME")) {
reportNO = value;
@@ -101,11 +102,6 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp)
// open report
clientDoc = ReportClientDocument.openReport(file);
- // set Database connection
- CRJavaHelper.changeDataSource(clientDoc, username, password, url, driverClassName, jndiName);
- // save it, so that could directly login, change data source is slowly.
- clientDoc.save();
-
// Check/Set report param
List reportParams = CRJavaHelper.getTopParams(clientDoc);
for (String param : reportParams) {
@@ -132,6 +128,18 @@ public void handReportRequest(HttpServletRequest req, HttpServletResponse resp)
summaryInfo.setTitle(reportNO);
clientDoc.setSummaryInfo(summaryInfo);
+ // set Database connection
+ CRJavaHelper.changeDataSource(
+ clientDoc,
+ username,
+ password,
+ url,
+ driverClassName,
+ jndiName,
+ report + ".rpt",
+ reportsPath
+ );
+
// export report
switch (format) {
case "pdf":
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 70bd725..be2611a 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -12,6 +12,5 @@ project.dependencies = @project.dependencies@
#rpt.datasource.driverClassName = org.postgresql.Driver
#rpt.datasource.username = postgres
#rpt.datasource.password = postgres
-#rpt.datasource.jndiName = jdbc/SageDB
spring.profiles.active = prod
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
index 09257a1..6d853ad 100644
--- a/src/main/resources/log4j2.xml
+++ b/src/main/resources/log4j2.xml
@@ -9,14 +9,13 @@
-
+
-
+
${patternConsole}
-
+
${patternFile}
@@ -38,7 +37,7 @@
-
+
@@ -49,11 +48,14 @@
-
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/com/da/crystal/report/ReportFunctionTests.java b/src/test/java/com/da/crystal/report/ReportFunctionTests.java
index 20957cc..8ae02e1 100644
--- a/src/test/java/com/da/crystal/report/ReportFunctionTests.java
+++ b/src/test/java/com/da/crystal/report/ReportFunctionTests.java
@@ -1,11 +1,11 @@
-/*********************************************************************************************************************
- * @Author : Robert Huang<56649783@qq.com> *
- * @CreatedDate : 2023-04-12 19:43:00 *
- * @LastEditors : Robert Huang<56649783@qq.com> *
- * @LastEditDate : 2023-06-28 11:16:47 *
- * @FilePath : src/test/java/com/da/crystal/report/ReportFunctionTests.java *
- * @CopyRight : Dedienne Aerospace China ZhuHai *
- ********************************************************************************************************************/
+/**********************************************************************************************************************
+ * @Author : Robert Huang<56649783@qq.com> *
+ * @CreatedDate : 2023-04-12 19:43:00 *
+ * @LastEditors : Robert Huang<56649783@qq.com> *
+ * @LastEditDate : 2023-10-19 10:32:10 *
+ * @FilePath : src/test/java/com/da/crystal/report/ReportFunctionTests.java *
+ * @CopyRight : Dedienne Aerospace China ZhuHai *
+ *********************************************************************************************************************/
package com.da.crystal.report;
@@ -29,6 +29,7 @@
import com.crystaldecisions.sdk.occa.report.definition.Paragraphs;
import com.crystaldecisions.sdk.occa.report.definition.ReportObjects;
import com.crystaldecisions.sdk.occa.report.document.ISummaryInfo;
+import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;
import com.crystaldecisions.sdk.occa.report.lib.ReportObjectKind;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
@@ -38,7 +39,8 @@
public class ReportFunctionTests {
private ReportClientDocument clientDoc = null;
- String reportsPath = Thread.currentThread().getContextClassLoader().getResource("").getPath() + "../reports/";
+ String reportsPath =
+ Thread.currentThread().getContextClassLoader().getResource("").getPath() + "../classes/reports/";
@Test
void saveRptTest() throws ReportSDKException, IOException {
@@ -52,7 +54,8 @@ void saveRptTest() throws ReportSDKException, IOException {
clientDoc.setSummaryInfo(summaryInfo);
clientDoc.saveAs("Modified.rpt", reportsPath, 1); // 1 over write
-
+ clientDoc.close();
+
file = new File(reportsPath + "Modified.rpt"); // open it to verify
clientDoc = ReportClientDocument.openReport(file);
@@ -77,6 +80,18 @@ void getResultFieldTest() throws ReportSDKException, IOException {
clientDoc.close();
}
+ @Test
+ void exportRptFormatListTest() throws ReportSDKException, IOException {
+ File file = new File(reportsPath + "TEST.rpt");
+ clientDoc = ReportClientDocument.openReport(file);
+ PropertyBag propertyBag = clientDoc.getAvailableExportFormats(reportsPath, false);
+
+ for (var key : propertyBag.keySet()) {
+ log.debug("{}", propertyBag.get(key));
+ }
+ clientDoc.close();
+ }
+
@Test
void getTableLinksTest() throws ReportSDKException, IOException {
File file = new File(reportsPath + "TEST.rpt");