Getting started with POI
POI Quick Start
Seven steps required for POI development:
1. Create a WorkBook object
Workbook wb = new HSSFWorkbook (); // It is used to operate excel 2003
2. Create a worksheet Sheet object
Sheet sheet = wb. createSheet ();
3. Create a row object
Row nRow = sheet. createRow (number of rows );
4. Create a Cell Object
Cell nCell = nRow. createCell (number of columns );
5. Write content
NCell. setCellValue (content to be written );
6. Modify
CellStyle style = wb. createCellStyle (); // create a style object
Font font = wb. createFont (); // create a Font object
Font. setFontName (font); // set the font
Font. setFontHeightInPoints (font size); // set the font size
Style. setFont (font); // bind the font
NCell. setCellStyle (style); // apply the style
7. Save and close
OutputStream OS = new FileOutputStream (new File (File storage path ));
Wb. write (OS );
OS. flush ();
OS. close ();