POI怎样通过模版是一个Excel表格获得模版的各种设置

现在有一个空白的Excel模版,不过模版里面有单元格的各种格式,请问怎么样通过POI 实现将一个有数据的excel文件通过模版,生存具有模版文件所有设置的新文件,求代码,最好详细点谢谢!

[code="java"]
public class ExporTest {
private Map smap;// 存储模板中单元格样式
@Test
public void test() {
Workbook wb = getWorkbook(path);
initStyle(wb);
writeSheet(wb.getSheetAt(1));
writeExcel(wb);
}

private Workbook getWorkbook(String filepath) {

    Workbook wb = null;
    try {
        wb = new XSSFWorkbook(filepath);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return wb;
}

/**
 * 从模板中取单元格样式,
 * 
 * @param wb
 */
private void initStyle(Workbook wb) {

    CellStyle normal = wb.getSheetAt(0).getRow(5).getCell(0).getCellStyle();
    smap.put("normal", normal);
}

private void writeSheet(Sheet sh) {

    for (int i = 0; i < ps.size(); i++) {
        Row row = sh.createRow(i + 1);
        Cell cell = row.createCell(0);
        cell.setCellStyle(smap.get("normal"));
        cell.setCellValue(permission.getName());
    }
}

private void writeExcel(Workbook wb) {

    try {
        FileOutputStream out = new FileOutputStream("test.xls");
        wb.write(out);
        out.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

}
[/code]

随便搜一下POI吧,很多的