Java export Excel Sheet
1. Problem background
When exporting an Excel table, you must first generate a Sheet page. The following describes how to generate a Sheet page.
2. Source Code
/**
*
* @ Project:
* @ Title: ExcelExport. java
* @ Package: report. utils
* @ Description:
* @ Author: YouHaiDong
* @ Date: 6:29:22, January 1, November 2, 2015
* @ Version:
*/
Package report. utils;
Import java. io. FileNotFoundException;
Import java. io. FileOutputStream;
Import java. io. IOException;
Import org. apache. poi. hssf. usermodel. HSSFSheet;
Import org. apache. poi. hssf. usermodel. HSSFWorkbook;
/**
*
Export Excel
* @ ClassName: ExcelExport
* @ Description:
* @ Author: YouHaiDong
* @ Date: 6:29:22, January 1, November 2, 2015
*
*/
Public class ExcelExport
{
/**
* @ Title: ExcelExport
* @ Description:
* @ Param args
* @ Date: 6:29:22, January 1, November 2, 2015
* @ Return: void
* @ Throws
*/
@ SuppressWarnings ({"deprecation", "resource "})
Public static void main (String [] args)
{
HSSFWorkbook workbook = new HSSFWorkbook ();
// Set the sheet Page name
HSSFSheet sheet = workbook. createSheet ("Student table ");
Sheet. setdefacolumcolumnwidth (short) 15 );
FileOutputStream stream; try {// export the Excel student table stream = new FileOutputStream (d:/student.xls); workbook. write (stream);} catch (FileNotFoundException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();}}
}
3. Implementation result