|
@@ -17,10 +17,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
|
|
-import java.io.InputStream;
|
|
|
|
|
-import java.io.OutputStream;
|
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
|
+import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -48,9 +45,9 @@ public class ExcelUtils2 implements ResourceLoaderAware {
|
|
|
Resource template = resourceLoader.getResource(templateLoacation);
|
|
Resource template = resourceLoader.getResource(templateLoacation);
|
|
|
resp.setHeader("Content-Type", "application/vnd.ms-excel; charset=utf-8");
|
|
resp.setHeader("Content-Type", "application/vnd.ms-excel; charset=utf-8");
|
|
|
try {
|
|
try {
|
|
|
- //resp.setHeader("Transfer-Encoding", "chunked");
|
|
|
|
|
resp.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
|
|
resp.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
|
|
|
- //resp.setContentLength(getExcelFileSize(list));
|
|
|
|
|
|
|
+ logger.info("文件大小:" + template.getFile().length());
|
|
|
|
|
+ logger.info("文件大小2:" + template.contentLength());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
}
|
|
@@ -59,8 +56,6 @@ public class ExcelUtils2 implements ResourceLoaderAware {
|
|
|
InputStream is = template.getInputStream();
|
|
InputStream is = template.getInputStream();
|
|
|
OutputStream outputStream = resp.getOutputStream();
|
|
OutputStream outputStream = resp.getOutputStream();
|
|
|
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(is).build();
|
|
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(is).build();
|
|
|
- int totalSize = is.available(); //获取文件大小
|
|
|
|
|
- logger.info("压缩后===当前文件下载大小size={}", totalSize);
|
|
|
|
|
is.close();
|
|
is.close();
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
|
|
// 直接写入数据
|
|
// 直接写入数据
|