1. Introduce dependencies <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> </dependency> 2. Simple export implementation package cn.sto.station.twin.common.excel; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.ss.usermodel.*; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * SXSSFWorkbook export * […]
Tag: sxs
Realize the export function of custom header (using SXSSFWorkbook)
Export without template Effect display Code display: public AjaxResult exportTableData(UserColumn userColumn) {<!– –> // Get the total number of columns List<UserColumn> userColumns = userColumnMapper. getCloumn(userColumn); try {<!– –> //Start creating excel SXSSFWorkbook workBook = new SXSSFWorkbook(); // bold, vertical CellStyle boldStyle = workBook. createCellStyle(); Font font = workBook. createFont(); font.setBold(true); boldStyle. setFont(font); //add border CellStyle […]
[Solved] SXSSFWorkbook download Excel error: No such file or directory
Error message display: reason: The problem is that the file directory does not exist By default, poi exports the exported excel to the temporary directory of the system. The source code is as follows: If no temporary file directory is specified, it will use this default configuration, so as long as we pass TempFile.setTempFileCreationStrategy This […]