From: noboru saitoh Date: Sat, 6 Sep 2014 16:22:25 +0000 (+0900) Subject: サンプル作成 X-Git-Url: http://git.osdn.net/view?p=jaxcel%2Fjaxcel.git;a=commitdiff_plain;h=a5be1851c962e5ee9c717d96dd7aa29df65648b9 サンプル作成 TLパーサboolean判断不具合修正 --- diff --git a/Jaxcel/.settings/org.eclipse.core.resources.prefs b/Jaxcel/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 7c68b20..0000000 --- a/Jaxcel/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding//sample/bin/simple_EL_example.bat=ISO-8859-1 diff --git a/Jaxcel/sample/bin/object_EL_example.bat b/Jaxcel/sample/bin/object_EL_example.bat new file mode 100644 index 0000000..37f1e2e --- /dev/null +++ b/Jaxcel/sample/bin/object_EL_example.bat @@ -0,0 +1,3 @@ +java -classpath .\;..\..\build;..\..\lib\* org.hanei.jaxcel.example.MakeReportWithObject "../resources/object_EL_example.xlsx" "../output/object_EL_example_result.xlsx" +pause +EXIT /b 0 diff --git a/Jaxcel/sample/bin/object_array_example_xlsx.bat b/Jaxcel/sample/bin/object_array_example_xlsx.bat new file mode 100644 index 0000000..3e01ac8 --- /dev/null +++ b/Jaxcel/sample/bin/object_array_example_xlsx.bat @@ -0,0 +1,3 @@ +java -classpath .\;..\..\build;..\..\lib\* org.hanei.jaxcel.example.MakeReportWithObject "../resources/object_array_example.xlsx" "../output/object_array_example_result.xlsx" +pause +EXIT /b 0 diff --git a/Jaxcel/sample/bin/simple_EL_example.bat b/Jaxcel/sample/bin/simple_EL_example.bat deleted file mode 100644 index 8e6270f..0000000 --- a/Jaxcel/sample/bin/simple_EL_example.bat +++ /dev/null @@ -1,3 +0,0 @@ -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" -pause -EXIT /b 0 diff --git a/Jaxcel/sample/resources/object_EL_example.xlsx b/Jaxcel/sample/resources/object_EL_example.xlsx new file mode 100644 index 0000000..90b9a1b Binary files /dev/null and b/Jaxcel/sample/resources/object_EL_example.xlsx differ diff --git a/Jaxcel/sample/resources/object_array_example.xlsx b/Jaxcel/sample/resources/object_array_example.xlsx new file mode 100644 index 0000000..afc015b Binary files /dev/null and b/Jaxcel/sample/resources/object_array_example.xlsx differ diff --git a/Jaxcel/sample/resources/simple_table_example.xlsx b/Jaxcel/sample/resources/simple_table_example.xlsx index 02c7b86..6b53c2c 100644 Binary files a/Jaxcel/sample/resources/simple_table_example.xlsx and b/Jaxcel/sample/resources/simple_table_example.xlsx differ diff --git a/Jaxcel/src/org/hanei/jaxcel/example/MakeReportWithObject.java b/Jaxcel/src/org/hanei/jaxcel/example/MakeReportWithObject.java new file mode 100644 index 0000000..73981ff --- /dev/null +++ b/Jaxcel/src/org/hanei/jaxcel/example/MakeReportWithObject.java @@ -0,0 +1,103 @@ +/** + * Copyright 2014 Hanei Management Co.,Ltd. + * + * This file is part of Jaxcel + * + * Jaxcel is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaxcel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package org.hanei.jaxcel.example; + + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; +import org.hanei.jaxcel.report.ReportMaker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * JavaオブジェクトからのExcel帳票出力サンプルクラス + * + * @version 1.00.00 + * @author Noboru Saito + */ +public class MakeReportWithObject { + + private static final Logger log = LoggerFactory.getLogger(MakeReportWithObject.class); + + /** + * ExcelテンプレートファイルにJavaObjectサンプルデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。 + * + * @param args arg1: Excelテンプレートファイルパス
+ * arg2: パラメータJSONファイルパス
+ * arg3: Excel帳票出力ファイルパス + * + * @throws Exception + */ + public static void main(String[] args) throws Exception { + + if(args.length != 2) { + System.out.println("illegal arguments."); + System.out.println("arg1: template excel file path"); + System.out.println("arg2: output excel file path"); + System.out.println("...relative path from the build root. or absolute path"); + System.exit(0); + } + + // parameter + LinkedHashMap parameter = new LinkedHashMap<>(); + + // object data + SampleObject objData = new SampleObject(); + objData.setDataA("Hello"); + objData.setDataB(123); + objData.setDataC(1.23); + objData.setDataD(true); + objData.dataApub = "Jaxcel!!"; + objData.dataBpub = 456; + objData.dataCpub = 4.56; + objData.dataDpub = false; + parameter.put("objData", objData); + + // object array data + ArrayList aryData = new ArrayList<>(); + for(int i = 0; i < 10; i++) { + SampleObject aryObjData = new SampleObject(); + + aryObjData.setDataA(RandomStringUtils.randomAlphabetic(RandomUtils.nextInt(5, 10))); + aryObjData.setDataB(RandomUtils.nextInt(0, 1000)); + aryObjData.setDataC(RandomUtils.nextDouble(0, 1000)); + aryObjData.setDataD(BooleanUtils.toBoolean(RandomUtils.nextInt(0, 2))); + aryObjData.dataApub = (RandomStringUtils.randomAlphabetic(RandomUtils.nextInt(5, 10))); + aryObjData.dataBpub = RandomUtils.nextInt(0, 1000); + aryObjData.dataCpub = RandomUtils.nextDouble(0, 1000); + aryObjData.dataDpub = BooleanUtils.toBoolean(RandomUtils.nextInt(0, 2)); + + aryData.add(aryObjData); + } + parameter.put("arrayData", aryData); + + ReportMaker maker = new ReportMaker(); + log.info("====== makeReport Start ======"); + maker.makeReport(new File(args[0]), parameter, new File(args[1])); + System.out.println("output complate " + args[1]); + System.out.println("see debug log ../log/jaxcel.log"); + log.info("====== makeReport End ======"); + } + +} diff --git a/Jaxcel/src/org/hanei/jaxcel/example/SampleObject.java b/Jaxcel/src/org/hanei/jaxcel/example/SampleObject.java new file mode 100644 index 0000000..d4e1c6b --- /dev/null +++ b/Jaxcel/src/org/hanei/jaxcel/example/SampleObject.java @@ -0,0 +1,86 @@ +/** + * Copyright 2014 Hanei Management Co.,Ltd. + * + * This file is part of Jaxcel + * + * Jaxcel is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaxcel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package org.hanei.jaxcel.example; + +/** + * サンプルデータオブジェクト + * + * @author noboru saito + */ +public class SampleObject { + private String dataA; + private int dataB; + private double dataC; + private boolean dataD; + + public String dataApub; + public int dataBpub; + public double dataCpub; + public boolean dataDpub; + + /** + * @return dataA + */ + public String getDataA() { + return dataA; + } + /** + * @param dataA セットする dataA + */ + public void setDataA(String dataA) { + this.dataA = dataA; + } + /** + * @return dataB + */ + public int getDataB() { + return dataB; + } + /** + * @param dataB セットする dataB + */ + public void setDataB(int dataB) { + this.dataB = dataB; + } + /** + * @return dataC + */ + public double getDataC() { + return dataC; + } + /** + * @param dataC セットする dataC + */ + public void setDataC(double dataC) { + this.dataC = dataC; + } + /** + * @return dataD + */ + public boolean isDataD() { + return dataD; + } + /** + * @param dataD セットする dataD + */ + public void setDataD(boolean dataD) { + this.dataD = dataD; + } + +} diff --git a/Jaxcel/src/org/hanei/jaxcel/report/TLParser.java b/Jaxcel/src/org/hanei/jaxcel/report/TLParser.java index d82b9c7..0852411 100644 --- 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 { reParseFlg = false; } // 置換後の値がBool型 - else if(StringUtils.equalsIgnoreCase(newCellVal, "ture") || StringUtils.equalsIgnoreCase(newCellVal, "false")) { + else if(StringUtils.equalsIgnoreCase(newCellVal, "true") || StringUtils.equalsIgnoreCase(newCellVal, "false")) { // もともと文字列セルならBoolセルに変更し値をセット if(cell.getCellType() == Cell.CELL_TYPE_STRING) { cell.setCellType(Cell.CELL_TYPE_BLANK); diff --git a/Jaxcel/src/org/hanei/jaxcel/util/MakeReportTool.java b/Jaxcel/src/org/hanei/jaxcel/util/MakeReportTool.java index c521177..ebae546 100644 --- a/Jaxcel/src/org/hanei/jaxcel/util/MakeReportTool.java +++ b/Jaxcel/src/org/hanei/jaxcel/util/MakeReportTool.java @@ -1,3 +1,21 @@ +/** + * Copyright 2014 Hanei Management Co.,Ltd. + * + * This file is part of Jaxcel + * + * Jaxcel is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jaxcel is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ package org.hanei.jaxcel.util; import java.io.File; @@ -9,13 +27,18 @@ import org.hanei.jaxcel.report.ReportMaker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +/** + * Excel帳票出力コンソールツールクラス + * + * @version 1.00.00 + * @author Noboru Saito + */ public class MakeReportTool { private static final Logger log = LoggerFactory.getLogger(MakeReportTool.class); /** - * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。 + * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。
* * @param args arg1: Excelテンプレートファイルパス
* arg2: パラメータJSONファイルパス