Poi export excel and poiexcel

Source: Internet
Author: User

Poi export excel and poiexcel

I. Introduction

HSSF is the implementation of POI project's pure Java Excel97 (-2007) file format. XSSF is a Java implementation of the POI project Excel 2007 OOXML (.xlsx) file format. HSSF and XSSF provides multiple ways to read from, create, modify, read, and write workbooks.

It provides the following functions:

  • Provides a low-level structure for Special Needs
  • An efficient read-only access event model api
  • Provides an api for creating, reading, and modifying xls files.

Project URL: http://poi.apache.org/spreadsheet/index.html.

Ii. Instances

1. related dependencies are as follows:

<dependency>    <groupId>org.apache.poi</groupId>    <artifactId>poi</artifactId>    <version>3.12</version></dependency><dependency>    <groupId>org.apache.poi</groupId>    <artifactId>poi-ooxml</artifactId>    <version>3.12</version></dependency>

2. The sample code is as follows:

1 package com. test. excel; 2 3 import java. io. fileOutputStream; 4 import java. util. arrayList; 5 import java. util. list; 6 7 import org. apache. poi. ss. usermodel. cell; 8 import org. apache. poi. ss. usermodel. row; 9 import org. apache. poi. ss. usermodel. sheet; 10 import org. apache. poi. xssf. streaming. SXSSFWorkbook; 11 12/** 13*14 * excle export 15 */16 public class ExcelCreate {17 18/** 19 * excel generate 20 */21 public static void main (String [] args) throws Throwable {22 // header 23 List <String> headerList = new ArrayList <> (10); 24 for (int I = 1; I <= 10; I ++) {25 headerList. add ("Header" + I); 26} 27 28 // data 29 List <String []> dataRowList2 = new ArrayList <String []> (10 ); 30 for (int I = 1; I <= headerList. size (); I ++) {31 dataRowList2.add (new String [] {"data" + I, "data" + I, "data" + I}); 32} 33 34 SXSSFWorkbook workbook = new SXSSFWorkbook (90); 35 Sheet sheet = workbook. createSheet ("Export"); 36 37 int rownum = 0; 38 // header 39 Row row = sheet. createRow (rownum ++); 40 for (int I = 0; I 

3. The running result is as follows:

  

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.