poi学习
需要节点
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17-beta1</version>
</dependency>
private Integer id;
private String name;
private Integer age; 在测试类中编写代码:
//插入单行数据
@Test
public void hssTmp() throws IOException {
HSSFWorkbook wk=new HSSFWorkbook();
HSSFSheet sheet=wk.createSheet("学生表");
HSSFRow row=sheet.createRow(0);
HSSFCell cell=row.createCell(0);//此时后面不能+".setCellValue("")",否则会报错
cell.setCellValue("学生成绩表");
sheet.addMergedRegion(new CellRangeAddress(0,0,0,2));
HSSFRow row1 =sheet.createRow(1);
row1.createCell(0).setCellValue("学生编号");
row1.createCell(1).setCellValue("学生姓名");
row1.createCell(2).setCellValue("学生年龄"); HSSFRow row2 =sheet.createRow(2);
row2.createCell(0).setCellValue("1");
row2.createCell(1).setCellValue("张三");
row2.createCell(2).setCellValue("20");
FileOutputStream outputStream=new FileOutputStream("E:\\workbook.xls");
wk.write(outputStream);
outputStream.flush();
}
//将集合数据插入文件
@Test
public void outExcel() throws IOException {
HSSFWorkbook wk=new HSSFWorkbook();
HSSFSheet sheet=wk.createSheet("学生表"); HSSFRow row =sheet.createRow(0); HSSFCell cell=row.createCell(0);
cell.setCellValue("学生编号");
cell=row.createCell((short)1); cell.setCellValue("学生姓名");
cell=row.createCell((short)2); cell.setCellValue("学生年龄");
cell=row.createCell((short)3); List<Student> list=new ArrayList<Student>();
Student stu1=new Student();
stu1.setId(1);
stu1.setName("张三");
stu1.setAge(20); Student stu2=new Student();
stu2.setId(2);
stu2.setName("李四");
stu2.setAge(20); Student stu3=new Student();
stu3.setId(3);
stu3.setName("王五");
stu3.setAge(20); for (short i=0; i<list.size();i++ ){
row=sheet.createRow(i+1);
row.createCell(0).setCellValue(list.get(i).getId());
row.createCell(1).setCellValue(list.get(i).getId());
row.createCell(2).setCellValue(list.get(i).getId());
}
}
poi学习的更多相关文章
- itext poi 学习之旅 (3)读取数据库信息并由excel展现出来
DBConnection.java 连接数据库操作 package com.zkbj.poi; import java.sql.Connection; import java.sql.DriverMa ...
- itext poi 学习之旅 (2)创建excel
Computer.java package com.qiang.poi; public class Computer { private int id; private String name; pr ...
- itext poi 学习之旅 (1)创建pdf
从零开始学习itext 创建pdf 1.用到流进行创建的pdf import java.io.File; import java.io.FileOutputStream; import com.ite ...
- Android学习笔记之使用百度地图实现Poi搜索
PS:装个系统装了一天.心力憔悴.感觉不会再爱了. 学习内容: 1.使用百度Map实现Poi搜索. 2.短串分享 3.在线建议查询 百度地图的研究也算是过半了.能够实现定位,实现相关信息的搜索,实 ...
- [LBS学习笔记4]地理特征POI、AOI、路径轨迹
1 简述 今天继续LBS地理信息的学习,目标是写到10篇博客的时候,做出一个地图工具页面用,包含地图空间索引Geohash.S2.H3的可视化展示. 地理特征分为点(POI).线(路径).面(AOI) ...
- 一脸懵逼学习Java操作Excel之POI(Apache POI)
Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能. 1:下面简单的程序来创建一个空白Microsoft ...
- Spring Boot学习笔记----POI(Excel导入导出)
业务:动态生成模板导出Excel,用户修改完再导入Excel. Spring boot + bootstrap + poi 1.添加Dependence <dependency> < ...
- GIS学习 Geoserver使用添加、删除、查询地图中的POI
geoserverwfs:Querywfs:Deletewfs:Updatewfs:Insert 在geoserver自定义的地图中通过geoserver wfs 查询,删除,添加相关的POI. 相 ...
- Java程序员的日常—— POI与JDBC、Mockmvc与单元测试
周日没怎么休息好,周一一天都迷迷糊糊的,不过还算是干了不少的活. 总结一下,大致有以下几点内容: 1 使用poi以及mysql jdbc实现了一个复杂excel的导入 2 基于工程原有的代码,书写sp ...
随机推荐
- postgreSQL PL/SQL编程学习笔记(四)
Errors and Messages 1. Reporting Errors and Messages Use the RAISE statement to report messages and ...
- [USACO08DEC]拍头Patting Heads 数学 BZOJ 1607
题目描述 It's Bessie's birthday and time for party games! Bessie has instructed the N (1 <= N <= 1 ...
- 文件管理NSFileManager
//NSFileManager - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@",NSHomeDirectory()); ...
- redux超易学三篇之二(开始使用react-redux)
其实 redux 真正让人感到混乱的还是在 react-redux 的使用中. 请配合完整代码参考~:完整源代码 也不是说混乱,主要是网上 推崇 最佳实践.学习一个新东西的时候,本来就很陌生,上来就用 ...
- Docker 查看容器环境变量
#linux指令# printenv
- abp学习资料
参考: https://www.jianshu.com/p/a6e9ace79345
- 去掉小程序button元素的边框
button::after { display:none }
- C# Win7下隐藏手势提示
点击这里是原版答案 Stylus.IsFlicksEnabled="False" 手势是什么样子的
- 为什么我引用bootstrap的font-awesome的图标不出来,就单单是一个HTML里面引用的?
原文地址:https://www.zhihu.com/question/37015526?sort=created 24 个回答 知乎用户 我来猜猜: 1.检查字体路径是否加载对了2.font ...
- 子查询及pymysql
子查询 子查询指的是当一个查询语句被作为另一个查询语句的条件时,该查询语句就称之为子查询(内层查询) 可以将一个大问题 拆分几个小的问题 然后一步一步来查询 需求:财务不有哪些人 ),sex ),jo ...