使用poi将list集合中的数据导入excel表格并且导出到浏览器页面或者从excel中导出数据。

本文介绍了如何使用Java的poi库将list集合数据导入到excel并导出到浏览器,以及从excel文件中读取数据到list。内容包括导入poi坐标,实现数据导入导出的两个功能,并提到了jxl和easyexcel作为替代方案。
摘要由CSDN通过智能技术生成

使用poi将list集合中的数据导入excel表格并且导出到浏览器页面或者从excel中导出数据。

首先导入poi的坐标

	<!-- excel2003使用的包 -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.11</version>
		</dependency>
		<!-- excel2007+使用的包 -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
			<version>3.11</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml-schemas</artifactId>
			<version>3.11</version>
		</dependency>

实现功能一、将list集合中的数据导入excel表格并且导出到浏览器页面

@RestController
public class ClientUserInfoController {
   
    @Autowired
    private ClientUserInfoService teacherservice;
    @RequestMapping(value = "UserExcelDownloads", method = RequestMethod.GET)
    public void downloadAllClassmate(HttpServletResponse response) throws IOException {
   
        //1.第一步,创建一个03版的excel工作薄
        HSSFWorkbook workbook = new HSSFWorkbook();
        //2.使用工作薄对象创建一个工作表
        HSSFSheet sheet = workbook.createSheet("信息表");
        //3.从数据库中读取数据封装的list
        List<ClientInfo> classmateList = teacherservice.teacherinfor();
        //4.创建一个文件对象
        String fileName = "clientUserInfo"+ System.c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值