1 2 17 18 19 package org.apache.poi.hssf.usermodel.examples; 20 21 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 22 import org.apache.poi.hssf.usermodel.HSSFSheet; 23 import org.apache.poi.hssf.usermodel.HSSFRow; 24 import org.apache.poi.hssf.usermodel.HSSFCell; 25 26 import java.io.FileOutputStream ; 27 import java.io.IOException ; 28 29 34 public class CreateCells 35 { 36 public static void main(String [] args) 37 throws IOException 38 { 39 HSSFWorkbook wb = new HSSFWorkbook(); 40 HSSFSheet sheet = wb.createSheet("new sheet"); 41 42 HSSFRow row = sheet.createRow((short)0); 44 HSSFCell cell = row.createCell((short)0); 46 cell.setCellValue(1); 47 48 row.createCell((short)1).setCellValue(1.2); 50 row.createCell((short)2).setCellValue("This is a string"); 51 row.createCell((short)3).setCellValue(true); 52 53 FileOutputStream fileOut = new FileOutputStream ("workbook.xls"); 55 wb.write(fileOut); 56 fileOut.close(); 57 } 58 } 59 | Popular Tags |