FileDocCategorySizeDatePackage
CreateCells.javaAPI DocApache Poi 3.0.12182Mon Jan 01 12:39:42 GMT 2007org.apache.poi.hssf.usermodel.examples

CreateCells

public class CreateCells extends Object
Illustrates how to create cell values.
author
Glen Stampoultzis (glens at apache.org)

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("new sheet");

        // Create a row and put some cells in it. Rows are 0 based.
        HSSFRow row = sheet.createRow((short)0);
        // Create a cell and put a value in it.
        HSSFCell cell = row.createCell((short)0);
        cell.setCellValue(1);

        // Or do it on one line.
        row.createCell((short)1).setCellValue(1.2);
        row.createCell((short)2).setCellValue("This is a string");
        row.createCell((short)3).setCellValue(true);

        // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream("workbook.xls");
        wb.write(fileOut);
        fileOut.close();