Commit f5231ade by jinxin

群发记录导出

parent 4062b871
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>5.2.2</version> <version>3.9</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>5.2.2</version> <version>3.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
......
package com.gic.haoban.manage.web.qo; package com.gic.haoban.manage.web.qo;
import lombok.Data;
import java.util.List; import java.util.List;
/** /**
...@@ -9,7 +7,6 @@ import java.util.List; ...@@ -9,7 +7,6 @@ import java.util.List;
* @Author: wenhua * @Author: wenhua
* @Date: 2023/9/12 11:19 * @Date: 2023/9/12 11:19
*/ */
@Data
public class ExcelSheet { public class ExcelSheet {
/*** sheet的名称*/ /*** sheet的名称*/
private String fileName; private String fileName;
...@@ -20,6 +17,30 @@ public class ExcelSheet { ...@@ -20,6 +17,30 @@ public class ExcelSheet {
/*** sheet里的数据集*/ /*** sheet里的数据集*/
private List<String[]> dataset; private List<String[]> dataset;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String[] getHanders() {
return handers;
}
public void setHanders(String[] handers) {
this.handers = handers;
}
public List<String[]> getDataset() {
return dataset;
}
public void setDataset(List<String[]> dataset) {
this.dataset = dataset;
}
public ExcelSheet(String fileName, String[] handers, List<String[]> dataset) { public ExcelSheet(String fileName, String[] handers, List<String[]> dataset) {
this.fileName = fileName; this.fileName = fileName;
this.handers = handers; this.handers = handers;
......
...@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.utils; ...@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.utils;
import com.gic.haoban.manage.web.qo.ExcelSheet; import com.gic.haoban.manage.web.qo.ExcelSheet;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -25,9 +26,9 @@ public class ExportSheetUtil { ...@@ -25,9 +26,9 @@ public class ExportSheetUtil {
//表头样式 //表头样式
HSSFCellStyle style = wb.createCellStyle(); HSSFCellStyle style = wb.createCellStyle();
// 垂直 // 垂直
style.setVerticalAlignment(VerticalAlignment.CENTER); style.setVerticalAlignment(CellStyle.ALIGN_CENTER);
// 水平 // 水平
style.setAlignment(HorizontalAlignment.CENTER); style.setAlignment(CellStyle.VERTICAL_CENTER);
//字体样式 //字体样式
HSSFFont fontStyle = wb.createFont(); HSSFFont fontStyle = wb.createFont();
fontStyle.setFontName("微软雅黑"); fontStyle.setFontName("微软雅黑");
...@@ -73,7 +74,6 @@ public class ExportSheetUtil { ...@@ -73,7 +74,6 @@ public class ExportSheetUtil {
response.setHeader("Cache-Control", "No-cache"); response.setHeader("Cache-Control", "No-cache");
response.flushBuffer(); response.flushBuffer();
wb.write(response.getOutputStream()); wb.write(response.getOutputStream());
wb.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment