1
2
3
4
5 package oscon2006.common;
6
7 import java.io.*;
8 import org.apache.poi.hssf.*;
9 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
10 import au.com.bytecode.opencsv.*;
11
12 public class csv2xls
13 {
14 static private String argCsvFilename;
15
16 /**
17 *
18 * @param args
19 *
20 */
21 public static void main(String[] args)
22 {
23 if (args.length != 1)
24 {
25 System.exit(1);
26 }
27
28 processArgs(args);
29
30 InputStream in = null;
31
32 String xlsFilename = "output.xls";
33
34 try
35 {
36 in = new FileInputStream(argCsvFilename);
37
38 CSVReader r = new CSVReader( new InputStreamReader(in));
39
40 XlsBuilder builder = new XlsBuilder();
41 builder.setData(r);
42 builder.build(xlsFilename);
43 }
44 catch (Exception ex)
45 {
46 ex.printStackTrace();
47 }
48 finally
49 {
50 try
51 {
52 in.close();
53 }
54 catch (IOException ignore)
55 {
56
57 }
58
59 }
60
61 }
62
63 static private void processArgs(String[] args)
64 {
65 for (int index = 0; index < args.length; index++)
66 {
67 String arg = args[index];
68 argCsvFilename = args[index];
69 }
70 }
71 }