Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to export with springboot+easypoi excel with large amount of data

Shulou Source: shulou.com Published: 2022-06-02 06:40:46 09月25日 Update

This article mainly explains "how to use springboot+easypoi to export a large amount of data from excel". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to use springboot+easypoi large amount of data excel export" bar!

01

The last time I wrote a line of code to solve the export import, the little partner who did not read it suggested that we should first take a look at "one line of code to do Excel import and export", but there is a problem in the actual business. If the data is relatively large, for example, 10w + data will be exported once, it will get stuck. Continue to look at the official documents. There is a large amount of data export method, which is implemented as follows.

@ RequestMapping ("export") public void export (HttpServletResponse response) {Map params = new HashMap (); Workbook workbook = bigExcel (1, params, null, new ExportParams ("King of the Sea Thief", "King of the Sea Thief"), new Page (); ExcelExportUtil.closeExportBigExcel (); downLoadExcel ("King of the Sea Thief", response, workbook);} private Workbook bigExcel (int pageNum, Map params, Workbook workbook, ExportParams exportParams, Page page) {page.setCurrent (pageNum); page.setSize (1000) Page.setCondition (params); page = this.getData (sysUserService.queryPage (page)); List users = FastJsonUtils.toList (FastJsonUtils.toJSONString (page.getRecords ()), SysUser.class); workbook = ExcelExportUtil.exportBigExcel (exportParams, SysUser.class, users); if (page.getPages () > pageNum) {bigExcel (pageNum + 1, params, workbook, exportParams, page);} return workbook } private void downLoadExcel (String fileName, HttpServletResponse response, Workbook workbook) {try {response.setCharacterEncoding ("UTF-8"); response.setHeader ("Content-Disposition", "attachment;filename=" > response.setHeader ("content-Type", "application/vnd.ms-excel"); workbook.write (response.getOutputStream ());} catch (IOException e) {throw new NormalException (e.getMessage ()) }} at this point, I believe you have a deeper understanding of "how to export with springboot+easypoi excel with large amounts of data". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Data Sea Thief Sea Thief King one line code content practice method learning practical deeper business interest official practical boy partner suggestion situation simple operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Docker Xiaomi Huawei