poi 第一天

public class Test {

public static void main(String[] args) {
// TODO Auto-generated method stub
String[] topicArray = new String[]{"id","names"};
File file = new File("I:\\workbook\\workbook.xlsx");

OutputStream output = null;
try {
output = new FileOutputStream(file);
// POIFSFileSystem fileSystem = new POIFSFileSystem(file);
HSSFWorkbook workbook = new HSSFWorkbook();
// HSSFSheet sheet = workbook.createSheet("zhangxiongfeng");
createSheet(workbook);
workbook.write(output);
output.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

/**
* 创建cell
* */
public static void createSheet(HSSFWorkbook workbook){
HSSFSheet sheet = workbook.createSheet("zhangxiongfeng");
for(int i = 0 ; i < 9; i++){
HSSFRow row = sheet.createRow(i);
for(int j = 0 ; j < 10; j++){
HSSFCell cell = row.createCell(j, CellType.STRING);
cell.setCellValue("sss"+j);
}
}


}

}

posted @ 2017-07-06 21:55  随风而逝,只是飘零  阅读(73)  评论(0编辑  收藏  举报