• 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、实现结果
    这里写图片描述

  • 相关阅读:
    layer-list:Android中layer-list使用详解
    Nexus6p:正在下载系统更新,没有进度
    转:浅谈char类型范围
    C/C++/Java中的volatile关键字
    C++中的mutable关键字
    C++中的typedef typename 作用
    C++中的友元函数和友元类
    用flashfxp做ftp镜像同步
    python读取caffemodel文件
    py-faster-rcnn几个辅助脚本
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314339.html
Copyright © 2020-2023  润新知