OSDN Git Service

c52117765e2c2f32621d6f8a79d2c9fe71d08d00
[jaxcel/jaxcel.git] / Jaxcel / src / org / hanei / jaxcel / util / MakeReportTool.java
1 package org.hanei.jaxcel.util;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.InputStreamReader;
6 import java.util.HashMap;
7 import net.arnx.jsonic.JSON;
8 import org.hanei.jaxcel.report.ReportMaker;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11
12
13 public class MakeReportTool {
14
15         private static final Logger log = LoggerFactory.getLogger(MakeReportTool.class);
16
17         /**
18          * ExcelテンプレートファイルにJSONファイルのデータを挿入することでExcel帳票を生成、Excel帳票ファイルを出力する。
19          * 
20          * @param args arg1: Excelテンプレートファイルパス<br>
21          * arg2: パラメータJSONファイルパス<br>
22          * arg3: Excel帳票出力ファイルパス
23          * 
24          * @throws Exception 
25          */
26         public static void main(String[] args) throws Exception {
27                 
28                 if(args.length != 3) {
29                         System.out.println("illegal arguments.");
30                         System.out.println("arg1: template excel file path");
31                         System.out.println("arg2: parameters json file path");
32                         System.out.println("arg3: output excel file path");
33                         System.out.println("...relative path from the build root. or absolute path");
34                         System.exit(0);
35                 }
36                 // data load
37                 HashMap<String, Object> parameter = JSON.decode(new InputStreamReader(new FileInputStream(new File(args[1])),"UTF-8"));
38                 
39                 ReportMaker maker = new ReportMaker();
40                 log.info("====== makeReport Start ======");
41                 maker.makeReport(new File(args[0]), parameter, new File(args[2]));
42                 System.out.println("output complate " + args[2]);
43                 System.out.println("see debug log ../log/jaxcel.log");
44                 log.info("====== makeReport End ======");
45         }
46
47 }