Getting started with POI

Source: Internet
Author: User

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 ();

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.