// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.*;

import org.apache.poi.hssf.usermodel.*;

public class WritePOI {
   public static void main(String[] args) throws Exception {
      HSSFWorkbook book = new HSSFWorkbook();
       HSSFSheet sheet = book.createSheet("Test Sheet");
       sheet.setSelected(true);
       HSSFRow hdrrow = sheet.createRow((short)0);
       HSSFCell hdrrowcola = hdrrow.createCell((short)0);
       hdrrowcola.setCellValue("F1");
       HSSFCell hdrrowcolb = hdrrow.createCell((short)1);
       hdrrowcolb.setCellValue("F2");
       for(int i = 0; i < 10; i++) {
          HSSFRow datarow = sheet.createRow((short)(i+1));
          HSSFCell datacola = datarow.createCell((short)0);
          datacola.setCellValue(i+1);
          HSSFCell datacolb = datarow.createCell((short)1);
          datacolb.setCellValue("Dette er en test");
       }
       sheet.setColumnWidth((short)1, (short)(50*256));
       FileOutputStream f = new FileOutputStream("C:\\jjtest.xls");
       book.write(f);
       f.close();
   }
}
