|
@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.slf4j.Logger;
|
|
@@ -25,9 +26,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -653,13 +656,40 @@ public class PersonInfoController {
|
|
|
|
|
|
@ApiOperation(value="导出人员")
|
|
|
@PostMapping("exportXls")
|
|
|
- public MessageResult<String> exportXls(@RequestAttribute String subject){
|
|
|
- User user = userService.get(subject);
|
|
|
-
|
|
|
+ public MessageResult<String> exportXls(HttpServletRequest request, HttpServletResponse response){
|
|
|
MessageResult<String> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
+ //创建hssfWorkbook
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+
|
|
|
+ //创建工作簿
|
|
|
+ HSSFSheet sheet = workbook.createSheet("商品信息汇总");
|
|
|
+
|
|
|
+ //创建标题
|
|
|
+ //指定标题所在的行
|
|
|
+ HSSFRow row = sheet.createRow(0);
|
|
|
+ //指定标题所在的列
|
|
|
+ HSSFCell cell = row.createCell(0);
|
|
|
+ //设定单元格样式
|
|
|
+ HSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
|
+
|
|
|
+ HSSFFont font = workbook.createFont();
|
|
|
+ font.setFontName("黑体");
|
|
|
+ font.setFontHeightInPoints((short) 14);
|
|
|
+ cellStyle.setFont(font);
|
|
|
+
|
|
|
+ cellStyle.setFillBackgroundColor((short)56);
|
|
|
+
|
|
|
+ cell.setCellValue("商品信息汇总");
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+
|
|
|
|
|
|
+ //将exal输出到哪个文件夹中
|
|
|
+ FileOutputStream fileOutputStream = new FileOutputStream(new File("C:\\Users\\D.K\\Desktop\\test.xls"));
|
|
|
+ workbook.write(fileOutputStream);
|
|
|
+ fileOutputStream.close();
|
|
|
+ workbook.close();
|
|
|
}
|
|
|
catch(Exception ex){
|
|
|
logger.error(ex.getMessage(),ex);
|