使用poi将list集合中的数据导入excel表格并且导出到浏览器页面或者从excel中导出数据。
首先导入poi的坐标
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<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 {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("信息表");
List<ClientInfo> classmateList = teacherservice.teacherinfor();
String fileName = "clientUserInfo"+ System.c