急いでイソイテク

並盛り技術ダクダクで。

Apache POI メモ

インストール

Apache POI - Download Release Artifactsへアクセス後、
"The latest stable release is Apache POI 3.xx"
のリンクから辿って
"poi-bin-3.xx-20YYMMDD.zip"
のファイルをDLし、解凍し、とりあえず全部のjarを突っ込む。

書き始めテンプレ(成長中)

package XXXX;

import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class XXXX {

    public static void main(String[] args) throws IOException {

        String excelPath = args[0];
        String sheetName = args[1];

        MondaiExporter ins = new MondaiExporter();
        ins.execute(excelPath, sheetName);
    }

    public void execute(String excelPath, String sheetName) throws IOException {
        //
        // Excelファイルを開く
        //
        HSSFWorkbook wb = readFile(excelPath);

        //
        // シートを開く
        //
        HSSFSheet sheet = wb.getSheet(sheetName);

        //
        // 行のListを取得
        //

        //
        // 行ごとのループ
        //

        //
        // ファイルに書き出す
        //

    }

    private HSSFWorkbook readFile(String filename) throws IOException {
        FileInputStream fis = new FileInputStream(filename);
        try {
            return new HSSFWorkbook(fis);
        } finally {
            fis.close();
        }
    }
}

`