|
|
|
@ -29,10 +29,7 @@ import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@ -831,23 +828,18 @@ public class CollectController extends Controller {
|
|
|
|
|
if (type_id == 2) {
|
|
|
|
|
String pdfPath = excelPath.replace(".xlsx", ".pdf");
|
|
|
|
|
AsposeUtil.xls2pdf(excelPath, pdfPath);
|
|
|
|
|
HttpServletResponse response = getResponse();
|
|
|
|
|
BufferedInputStream br = new BufferedInputStream(new FileInputStream(pdfPath));
|
|
|
|
|
byte[] buf = new byte[1024];
|
|
|
|
|
int len;
|
|
|
|
|
response.reset(); // 非常重要
|
|
|
|
|
URL u = new URL("file:///" + pdfPath);
|
|
|
|
|
response.setContentType(u.openConnection().getContentType());
|
|
|
|
|
String fileName = pdf_filename;
|
|
|
|
|
response.setHeader("Content-Disposition", "inline; filename=" + fileName);
|
|
|
|
|
OutputStream out = response.getOutputStream();
|
|
|
|
|
while ((len = br.read(buf)) > 0) out.write(buf, 0, len);
|
|
|
|
|
br.close();
|
|
|
|
|
out.close();
|
|
|
|
|
/**
|
|
|
|
|
* 解决java.io.IOException: UT010029: Stream is closed报错
|
|
|
|
|
* 由于HttpServlet的request和response里的流都只能读写一次,关掉就没有了, 所以不能使用该方法
|
|
|
|
|
*/
|
|
|
|
|
OutputStream outputStream = getResponse().getOutputStream();
|
|
|
|
|
outputStream.write(FileUtil.readBytes(pdfPath));
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
renderNull();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:学校(单位)查看我该填报或者我已填报的任务列表
|
|
|
|
|
*
|
|
|
|
|