OSDN Git Service

#34479 対応中
[jaxcel/jaxcel.git] / Jaxcel / src / org / hanei / jaxcel / util / MakeReportTool.java
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.util;
20
21 import java.io.File;
22 import java.io.FileInputStream;
23 import java.io.InputStreamReader;
24 import java.util.HashMap;
25 import net.arnx.jsonic.JSON;
26 import org.hanei.jaxcel.report.ReportMaker;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 /**
31  * Excel帳票出力コマンドラインツールクラス
32  * 
33  * @since 1.00.00
34  * @author Noboru Saito
35  */
36 public class MakeReportTool {
37
38         private static final Logger log = LoggerFactory.getLogger(MakeReportTool.class);
39
40         /**
41          * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。<br>
42          * 
43          * @param args arg1: Excelテンプレートファイルパス<br>
44          *       arg2: パラメータJSONファイルパス<br>
45          *       arg3: Excel帳票出力ファイルパス
46          * 
47          * @throws Exception 
48          */
49         public static void main(String[] args) throws Exception {
50                 
51                 if(args.length != 3) {
52                         System.out.println("illegal arguments.");
53                         System.out.println("arg1: template excel file path");
54                         System.out.println("arg2: parameters json file path");
55                         System.out.println("arg3: output excel file path");
56                         System.out.println("...relative path from the build root. or absolute path");
57                         System.exit(0);
58                 }
59                 // data load
60                 HashMap<String, Object> parameter = JSON.decode(new InputStreamReader(new FileInputStream(new File(args[1])),"UTF-8"));
61                 
62                 ReportMaker maker = new ReportMaker();
63                 log.info("====== makeReport Start ======");
64                 maker.makeReport(new File(args[0]), parameter, new File(args[2]));
65                 System.out.println("output complate: " + args[2]);
66                 log.info("====== makeReport End ======");
67                 System.exit(0);
68         }
69
70 }