import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.*; public class Sample10_1{ public static void main(String[] args){ Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet(); Row[] row = new Row[2]; Cell[] cell = new Cell[2]; for (int i = 0 ; i < 2 ; i++){ row[i] = sheet.createRow(i + 1); cell[i] = row[i].createCell(2); cell[i].setCellValue("Thank you very much."); } CellStyle style0 = wb.createCellStyle(); style0.setWrapText(true); cell[0].setCellStyle(style0); CellStyle style1 = wb.createCellStyle(); style1.setWrapText(false); cell[1].setCellStyle(style1); FileOutputStream out = null; try{ out = new FileOutputStream("sample10_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()); } } } }