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 Sample5_1{
  public static void main(String[] args){
    Workbook wb = new HSSFWorkbook();
    Sheet sheet = wb.createSheet();
    sheet.setColumnWidth(1, 4096);
    sheet.setColumnWidth(2, 4096);

    Row row1 = sheet.createRow(1);
    Row row2 = sheet.createRow(2);

    Cell cell1_1 = row1.createCell(1);
    cell1_1.setCellValue("Sample");

    Cell cell2_1 = row2.createCell(1);
    cell2_1.setCellValue("Sample");

    Font font1 = wb.createFont();
    font1.setBoldweight(Font.BOLDWEIGHT_BOLD);
    font1.setFontHeightInPoints((short)14);

    Font font2 = wb.createFont();
    font2.setItalic(true);
    font2.setFontHeightInPoints((short)20);
    font2.setFontName("Century Gothic");

    CellStyle style1 = wb.createCellStyle();
    style1.setFont(font1);
    cell1_1.setCellStyle(style1);

    CellStyle style2 = wb.createCellStyle();
    style2.setFont(font2);
    cell2_1.setCellStyle(style2);

    FileOutputStream out = null;
    try{
      out = new FileOutputStream("sample5_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());
      }
    }
  }
}
