zoukankan      html  css  js  c++  java
  • Java导出Excel Sheet页

    1、问题背景
    导出Excel表格时,首先要生成Sheet页,下面将介绍如何生成Sheet页

    2、实现源码
    /**
    *
    * @Project:
    * @Title:ExcelExport.java
    * @Package:report.utils
    * @Description:
    * @Author:YouHaiDong
    * @Date:2015年11月2日 下午6:29:22
    * @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;

    /**
    *

    导出Excel


    * @ClassName:ExcelExport
    * @Description:
    * @Author:YouHaiDong
    * @Date:2015年11月2日 下午6:29:22
    *
    */
    public class ExcelExport
    {
    /**
    * @Title:ExcelExport
    * @Description:
    * @param args
    * @Date:2015年11月2日 下午6:29:22
    * @return: void
    * @throws
    */
    @SuppressWarnings({ “deprecation”, “resource” })
    public static void main(String[] args)
    {
    HSSFWorkbook workbook = new HSSFWorkbook();
    //设置sheet页名称
    HSSFSheet sheet = workbook.createSheet(“学生表”);
    sheet.setDefaultColumnWidth((short) 15);
        FileOutputStream stream;
        try 
        {
            //导出Excel学生表
            stream = new FileOutputStream("d:/student.xls");
            workbook.write(stream);
        } 
        catch (FileNotFoundException e) 
        {
            e.printStackTrace();
        }  
        catch (IOException e) 
        {
            e.printStackTrace();
        } 
    }
    

    }

    3、实现结果
    这里写图片描述

  • 相关阅读:
    @codeforces
    @codeforces
    @hdu
    @hdu
    @bzoj
    @bzoj
    @topcoder
    推荐系统主题相关资料
    Python统计百分比及排序
    如何发布及部署asp.net网站
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314339.html
Copyright © 2011-2022 走看看