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 Sample9_1{ public static void main(String[] args){ Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet(); Row[] row = new Row[4]; Cell[] cell = new Cell[4]; for (int i = 0 ; i < 4 ; i++){ row[i] = sheet.createRow(i + 1); cell[i] = row[i].createCell(2); cell[i].setCellValue("Coffee"); } CellStyle style0 = wb.createCellStyle(); style0.setRotation((short)45); cell[0].setCellStyle(style0); CellStyle style1 = wb.createCellStyle(); style1.setRotation((short)0); cell[1].setCellStyle(style1); CellStyle style2 = wb.createCellStyle(); style2.setRotation((short)-45); cell[2].setCellStyle(style2); CellStyle style3 = wb.createCellStyle(); style3.setRotation((short)-90); cell[3].setCellStyle(style3); FileOutputStream out = null; try{ out = new FileOutputStream("sample9_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()); } } } }