为了账号安全,请及时绑定邮箱和手机立即绑定

java导出excel多重表头

java导出excel多重表头

江户川乱折腾 2018-07-18 11:14:08
后台代码对多重表头要怎么排列?比如星期一下面还有早上,中午晚上,再下面才是动态数据!
查看完整描述

1 回答

?
沧海一幻觉

TA贡献1824条经验 获得超5个赞

package com.you.excel;

import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;

import org.apache.poi.hssf.usermodel.HSSFRow;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

/**

  • 请用一句话概括功能

  • @ClassName:ExcelExport

  • @Description:

  • @Author:YouHaiDong

  • @Date:2015年11月4日 下午2:23:49

  • */

    public class ExcelExport

    {

    /**


    • @Title:ExcelExport

    • @Description:

    • @param args

    • @Date:2015年11月4日 下午2:23:49

    • @return: void

    • @throws Exception 
      */

      @SuppressWarnings("resource")

      public static void main(String[] args) throws Exception

      {

      // 创建一个Workbook

      HSSFWorkbook workbook = new HSSFWorkbook();

      // 创建一个sheet页

      HSSFSheet sheet = workbook.createSheet("学生表");

      // 创建第一行

      HSSFRow row = sheet.createRow(0);

      // 创建单元格

      HSSFCell cell1 = row.createCell(0);

      HSSFCell cell2 = row.createCell(1);

      HSSFCell cell3 = row.createCell(2);

      HSSFCell cell4 = row.createCell(2);

      // 设置表头

      cell1.setCellValue("学号");

      cell2.setCellValue("姓名");

      cell3.setCellValue("性别");

      cell4.setCellValue("年龄");

      FileOutputStream stream = new FileOutputStream("d:/student.xls");

      workbook.write(stream);

      }

}


查看完整回答
反对 回复 2018-08-11
  • 1 回答
  • 0 关注
  • 2071 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号