• R/O
  • HTTP
  • SSH
  • HTTPS

jaxcel: 提交


Commit MetaInfo

修訂a5be1851c962e5ee9c717d96dd7aa29df65648b9 (tree)
時間2014-09-07 01:22:25
作者noboru saitoh <msnobosan@gmal...>
Commiternoboru saitoh

Log Message

サンプル作成
TLパーサboolean判断不具合修正

Change Summary

差異

--- a/Jaxcel/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
1-eclipse.preferences.version=1
2-encoding//sample/bin/simple_EL_example.bat=ISO-8859-1
--- /dev/null
+++ b/Jaxcel/sample/bin/object_EL_example.bat
@@ -0,0 +1,3 @@
1+java -classpath .\;..\..\build;..\..\lib\* org.hanei.jaxcel.example.MakeReportWithObject "../resources/object_EL_example.xlsx" "../output/object_EL_example_result.xlsx"
2+pause
3+EXIT /b 0
--- /dev/null
+++ b/Jaxcel/sample/bin/object_array_example_xlsx.bat
@@ -0,0 +1,3 @@
1+java -classpath .\;..\..\build;..\..\lib\* org.hanei.jaxcel.example.MakeReportWithObject "../resources/object_array_example.xlsx" "../output/object_array_example_result.xlsx"
2+pause
3+EXIT /b 0
--- a/Jaxcel/sample/bin/simple_EL_example.bat
+++ /dev/null
@@ -1,3 +0,0 @@
1-java -classpath ..\..\build;..\..\lib\* org.hanei.jaxcel.util.MakeReportTool "../resources/simple_EL_example.xlsx" "../resources/simple_EL_example.json" "../output/simple_EL_example_result.xlsx"
2-pause
3-EXIT /b 0
Binary files /dev/null and b/Jaxcel/sample/resources/object_EL_example.xlsx differ
Binary files /dev/null and b/Jaxcel/sample/resources/object_array_example.xlsx differ
Binary files a/Jaxcel/sample/resources/simple_table_example.xlsx and b/Jaxcel/sample/resources/simple_table_example.xlsx differ
--- /dev/null
+++ b/Jaxcel/src/org/hanei/jaxcel/example/MakeReportWithObject.java
@@ -0,0 +1,103 @@
1+/**
2+ * Copyright 2014 Hanei Management Co.,Ltd.
3+ *
4+ * This file is part of Jaxcel
5+ *
6+ * Jaxcel is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU Lesser General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * Jaxcel is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+package org.hanei.jaxcel.example;
20+
21+
22+import java.io.File;
23+import java.util.ArrayList;
24+import java.util.LinkedHashMap;
25+
26+import org.apache.commons.lang3.BooleanUtils;
27+import org.apache.commons.lang3.RandomStringUtils;
28+import org.apache.commons.lang3.RandomUtils;
29+import org.hanei.jaxcel.report.ReportMaker;
30+import org.slf4j.Logger;
31+import org.slf4j.LoggerFactory;
32+
33+/**
34+ * JavaオブジェクトからのExcel帳票出力サンプルクラス
35+ *
36+ * @version 1.00.00
37+ * @author Noboru Saito
38+ */
39+public class MakeReportWithObject {
40+
41+ private static final Logger log = LoggerFactory.getLogger(MakeReportWithObject.class);
42+
43+ /**
44+ * ExcelテンプレートファイルにJavaObjectサンプルデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。
45+ *
46+ * @param args arg1: Excelテンプレートファイルパス<br>
47+ * arg2: パラメータJSONファイルパス<br>
48+ * arg3: Excel帳票出力ファイルパス
49+ *
50+ * @throws Exception
51+ */
52+ public static void main(String[] args) throws Exception {
53+
54+ if(args.length != 2) {
55+ System.out.println("illegal arguments.");
56+ System.out.println("arg1: template excel file path");
57+ System.out.println("arg2: output excel file path");
58+ System.out.println("...relative path from the build root. or absolute path");
59+ System.exit(0);
60+ }
61+
62+ // parameter
63+ LinkedHashMap<String, Object> parameter = new LinkedHashMap<>();
64+
65+ // object data
66+ SampleObject objData = new SampleObject();
67+ objData.setDataA("Hello");
68+ objData.setDataB(123);
69+ objData.setDataC(1.23);
70+ objData.setDataD(true);
71+ objData.dataApub = "Jaxcel!!";
72+ objData.dataBpub = 456;
73+ objData.dataCpub = 4.56;
74+ objData.dataDpub = false;
75+ parameter.put("objData", objData);
76+
77+ // object array data
78+ ArrayList<SampleObject> aryData = new ArrayList<>();
79+ for(int i = 0; i < 10; i++) {
80+ SampleObject aryObjData = new SampleObject();
81+
82+ aryObjData.setDataA(RandomStringUtils.randomAlphabetic(RandomUtils.nextInt(5, 10)));
83+ aryObjData.setDataB(RandomUtils.nextInt(0, 1000));
84+ aryObjData.setDataC(RandomUtils.nextDouble(0, 1000));
85+ aryObjData.setDataD(BooleanUtils.toBoolean(RandomUtils.nextInt(0, 2)));
86+ aryObjData.dataApub = (RandomStringUtils.randomAlphabetic(RandomUtils.nextInt(5, 10)));
87+ aryObjData.dataBpub = RandomUtils.nextInt(0, 1000);
88+ aryObjData.dataCpub = RandomUtils.nextDouble(0, 1000);
89+ aryObjData.dataDpub = BooleanUtils.toBoolean(RandomUtils.nextInt(0, 2));
90+
91+ aryData.add(aryObjData);
92+ }
93+ parameter.put("arrayData", aryData);
94+
95+ ReportMaker maker = new ReportMaker();
96+ log.info("====== makeReport Start ======");
97+ maker.makeReport(new File(args[0]), parameter, new File(args[1]));
98+ System.out.println("output complate " + args[1]);
99+ System.out.println("see debug log ../log/jaxcel.log");
100+ log.info("====== makeReport End ======");
101+ }
102+
103+}
--- /dev/null
+++ b/Jaxcel/src/org/hanei/jaxcel/example/SampleObject.java
@@ -0,0 +1,86 @@
1+/**
2+ * Copyright 2014 Hanei Management Co.,Ltd.
3+ *
4+ * This file is part of Jaxcel
5+ *
6+ * Jaxcel is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU Lesser General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * Jaxcel is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+package org.hanei.jaxcel.example;
20+
21+/**
22+ * サンプルデータオブジェクト
23+ *
24+ * @author noboru saito
25+ */
26+public class SampleObject {
27+ private String dataA;
28+ private int dataB;
29+ private double dataC;
30+ private boolean dataD;
31+
32+ public String dataApub;
33+ public int dataBpub;
34+ public double dataCpub;
35+ public boolean dataDpub;
36+
37+ /**
38+ * @return dataA
39+ */
40+ public String getDataA() {
41+ return dataA;
42+ }
43+ /**
44+ * @param dataA セットする dataA
45+ */
46+ public void setDataA(String dataA) {
47+ this.dataA = dataA;
48+ }
49+ /**
50+ * @return dataB
51+ */
52+ public int getDataB() {
53+ return dataB;
54+ }
55+ /**
56+ * @param dataB セットする dataB
57+ */
58+ public void setDataB(int dataB) {
59+ this.dataB = dataB;
60+ }
61+ /**
62+ * @return dataC
63+ */
64+ public double getDataC() {
65+ return dataC;
66+ }
67+ /**
68+ * @param dataC セットする dataC
69+ */
70+ public void setDataC(double dataC) {
71+ this.dataC = dataC;
72+ }
73+ /**
74+ * @return dataD
75+ */
76+ public boolean isDataD() {
77+ return dataD;
78+ }
79+ /**
80+ * @param dataD セットする dataD
81+ */
82+ public void setDataD(boolean dataD) {
83+ this.dataD = dataD;
84+ }
85+
86+}
--- a/Jaxcel/src/org/hanei/jaxcel/report/TLParser.java
+++ b/Jaxcel/src/org/hanei/jaxcel/report/TLParser.java
@@ -562,7 +562,7 @@ public class TLParser {
562562 reParseFlg = false;
563563 }
564564 // 置換後の値がBool型
565- else if(StringUtils.equalsIgnoreCase(newCellVal, "ture") || StringUtils.equalsIgnoreCase(newCellVal, "false")) {
565+ else if(StringUtils.equalsIgnoreCase(newCellVal, "true") || StringUtils.equalsIgnoreCase(newCellVal, "false")) {
566566 // もともと文字列セルならBoolセルに変更し値をセット
567567 if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
568568 cell.setCellType(Cell.CELL_TYPE_BLANK);
--- a/Jaxcel/src/org/hanei/jaxcel/util/MakeReportTool.java
+++ b/Jaxcel/src/org/hanei/jaxcel/util/MakeReportTool.java
@@ -1,3 +1,21 @@
1+/**
2+ * Copyright 2014 Hanei Management Co.,Ltd.
3+ *
4+ * This file is part of Jaxcel
5+ *
6+ * Jaxcel is free software: you can redistribute it and/or modify
7+ * it under the terms of the GNU Lesser General Public License as published by
8+ * the Free Software Foundation, either version 3 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * Jaxcel is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
119 package org.hanei.jaxcel.util;
220
321 import java.io.File;
@@ -9,13 +27,18 @@ import org.hanei.jaxcel.report.ReportMaker;
927 import org.slf4j.Logger;
1028 import org.slf4j.LoggerFactory;
1129
12-
30+/**
31+ * Excel帳票出力コンソールツールクラス
32+ *
33+ * @version 1.00.00
34+ * @author Noboru Saito
35+ */
1336 public class MakeReportTool {
1437
1538 private static final Logger log = LoggerFactory.getLogger(MakeReportTool.class);
1639
1740 /**
18- * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。
41+ * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。<br>
1942 *
2043 * @param args arg1: Excelテンプレートファイルパス<br>
2144 * arg2: パラメータJSONファイルパス<br>
Show on old repository browser