import org.apache.poi.ss.usermodel.*; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.*; import java.util.Calendar; import java.util.Date; public class Sample6_1{ public static void main(String[] args){ Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet(); Row row = sheet.createRow(1); Cell cell0 = row.createCell(0); Cell cell1 = row.createCell(1); Cell cell2 = row.createCell(2); cell0.setCellValue(123); cell1.setCellValue(123); cell2.setCellValue(123); cell0.setCellType(Cell.CELL_TYPE_NUMERIC); cell1.setCellType(Cell.CELL_TYPE_STRING); cell2.setCellType(Cell.CELL_TYPE_BOOLEAN); FileOutputStream out = null; try{ out = new FileOutputStream("sample6_1.xls"); wb.write(out); }catch(IOException e){ System.out.println(e.toString()); }finally{ try { out.close(); }catch(IOException e){ System.out.println(e.toString()); } } } }