|
@@ -328,6 +328,7 @@ public class WbsTreeContractController extends BladeController {
|
|
|
public void downloadExcel(@RequestParam String pKeyId, HttpServletResponse response) {
|
|
|
com.spire.xls.Workbook workbook = null;
|
|
|
String htmlUrl = "";
|
|
|
+ String fileName = "";
|
|
|
try {
|
|
|
WbsTreeContract tab = iWbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
|
|
|
if (ObjectUtil.isEmpty(tab)) {
|
|
@@ -335,9 +336,11 @@ public class WbsTreeContractController extends BladeController {
|
|
|
WbsTreePrivate treePrivateTab = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
|
|
|
if (treePrivateTab != null && treePrivateTab.getHtmlUrl() != null) {
|
|
|
htmlUrl = treePrivateTab.getHtmlUrl();
|
|
|
+ fileName = ObjectUtil.isNotEmpty(treePrivateTab.getFullName()) ? treePrivateTab.getFullName() : treePrivateTab.getNodeName();
|
|
|
}
|
|
|
} else {
|
|
|
htmlUrl = tab.getHtmlUrl();
|
|
|
+ fileName = ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName();
|
|
|
}
|
|
|
|
|
|
if (ObjectUtil.isEmpty(htmlUrl)) {
|
|
@@ -346,7 +349,7 @@ public class WbsTreeContractController extends BladeController {
|
|
|
|
|
|
//将html转换为excel
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
- InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(tab.getHtmlUrl());
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(htmlUrl);
|
|
|
workbook = new com.spire.xls.Workbook();
|
|
|
workbook.loadFromHtml(inputStreamByUrl);
|
|
|
workbook.saveToStream(byteArrayOutputStream, FileFormat.Version2007);
|
|
@@ -407,7 +410,7 @@ public class WbsTreeContractController extends BladeController {
|
|
|
try (ServletOutputStream outputStream = response.getOutputStream();
|
|
|
ByteArrayOutputStream byteArrayOutputStreamResult = new ByteArrayOutputStream()) {
|
|
|
//设置响应头
|
|
|
- response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName(), "UTF-8") + ".xlsx");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
poiWorkbook.write(byteArrayOutputStreamResult);
|
|
|
byte[] excelBytesResult = byteArrayOutputStreamResult.toByteArray();
|