xlsx格式的写入的数据量据说有百万级,结合实际需要该格式。

public static void main(String[] args) throws Exception {
OutputStream outputStreamExcel = null;
File tmpFile = new File("E:" + File.separator + "file_route" + File.separator + "detail.xlsx");
if (!tmpFile.getParentFile().exists()) {
tmpFile.getParentFile().mkdirs();//创建目录
}
if(!tmpFile.exists()) {
tmpFile.createNewFile();//创建文件
}
Workbook workbook = null;
workbook = new XSSFWorkbook();//创建Workbook对象(excel的文档对象)
Sheet sheet1 = workbook.createSheet("Sheet1");// 建建sheet对象(excel的表单)
// 设置单元格字体
Font headerFont = workbook.createFont(); // 字体
headerFont.setFontHeightInPoints((short)14);
headerFont.setFontName("黑体");
// 设置单元格边框及颜色
CellStyle style = workbook.createCellStyle();
style.setBorderBottom((short)1);
style.setBorderLeft((short)1);
style.setBorderRight((short)1);
style.setBorderTop((short)1);
style.setWrapText(true); Row row = sheet1.createRow(0);
row.createCell(0).setCellValue("序号");
row.createCell(1).setCellValue("编号");
row.createCell(2).setCellValue("支付订单号");
row.createCell(3).setCellValue("商品订单号"); Row row1 = sheet1.createRow(1);
row1.createCell(0).setCellValue("10001");
row1.createCell(1).setCellValue("90001");
row1.createCell(2).setCellValue("1000000000012");
row1.createCell(3).setCellValue("9000000000099"); outputStreamExcel = new FileOutputStream(tmpFile);
workbook.write(outputStreamExcel);
outputStreamExcel.flush();
outputStreamExcel.close();
}

导入相应的jar包后,直接运行即可。

最新文章

  1. [svg 翻译教程]Polyline(折线)polygon(多边形)
  2. Heka 的编译 和 Heka 插件的编译
  3. jQuery学习-什么是jquery? Js与jquery之间的关系 Jquery选择器
  4. SSH服务器拒绝了密码,xshell连不上虚拟机怎么办
  5. lintcode: 最小调整代价
  6. memcachedd基础
  7. Helpers Overview
  8. buffer busy wait
  9. BZOJ 1497: [NOI2006]最大获利( 最大流 )
  10. ajenti试用感受
  11. hibernate 延长加载范围 4.2
  12. Step one : 熟悉HTML
  13. 初步了解 Django Models
  14. Java面试题——中级(下)
  15. 【一天一道LeetCode】#232. Implement Queue using Stacks
  16. 多个div实现随意拖拽功能
  17. (后端)mybatis中使用Java8的日期LocalDate、LocalDateTime
  18. git 合并多个commit
  19. canvas 实现弹跳效果
  20. Spring Boot 启动载入数据 CommandLineRunner

热门文章

  1. NRF52840相对于之前的NRF52系列、NRF51系列增加了什么功能
  2. mybatis源码追踪2——将结果集映射为map
  3. mybatis源码追踪1——Mapper方法用法解析
  4. 利用DNSlog回显Weblogic(CVE-2017-10271) 漏洞执行命令结果
  5. Nginx+Tomcat搭建负载均衡
  6. D09——C语言基础学PYTHON
  7. Backing Up and Restoring HBase Data
  8. 搜集C++实现的线程池
  9. 搭建互联网架构学习--006--duboo准备之zk集群部署安装
  10. Postman—做各种类型的http接口测试