java中Excel导出模板

1、首先在pom文件中导入poi的jar:

<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<exclusions>
				<exclusion>
					<artifactId>commons-collections4</artifactId>
					<groupId>org.apache.commons</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<artifactId>commons-collections4</artifactId>
			<groupId>org.apache.commons</groupId>
			<version>4.4</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml-schemas</artifactId>
</dependency>
2、后端代码如下:
public void getExportListToFinancialOut(HttpServletResponse response, HttpServletRequest request,
														   FinacialOutParam finacialOutParam) {
   													   
		//1、查询结果集
		List<FinacialOutVo> exportList = accountInfoDao.selecFinancialOutToExport(finacialOutParam);
		
		//2、将结果集打包,准备生成Excel(注意:String[]拼接的顺序就是生成后Excel表头的顺序)
		List<String[]> resultList = new ArrayList<>();
		for(FinacialOutVo finacialOutVo : exportList){
   
			String[] strings = new String[]{
   
					finacialOutVo.getUniquelyNum()

你可能感兴趣的:(Java,java,excel,apache)