Javaでexcelファイルを作成するサンプル

Javaコード:
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelOp{
public static void main(String[] args){
XSSFWorkbook workbook = new XSSFWorkbook();

workbook.createSheet(“tanhen”);

FileOutputStream out = null;
try{
out = new FileOutputStream(“precdf.xlsx”);
workbook.write(out);
}catch(IOException e){
System.out.println(e.toString());
}finally{
try {
out.close();
}catch(IOException e){
System.out.println(e.toString());
}
}
}
}

Comments are closed.