@@ -34,14 +34,14 @@ public final class ExcelCache { | |||||
} | } | ||||
return wb; | return wb; | ||||
} catch (InvalidFormatException e) { | } catch (InvalidFormatException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} finally { | } finally { | ||||
try { | try { | ||||
is.close(); | is.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
@@ -25,12 +25,12 @@ public class WordCache { | |||||
MyXWPFDocument doc = new MyXWPFDocument(is); | MyXWPFDocument doc = new MyXWPFDocument(is); | ||||
return doc; | return doc; | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} finally { | } finally { | ||||
try { | try { | ||||
is.close(); | is.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
@@ -34,9 +34,9 @@ class FileLoade { | |||||
baos.flush(); | baos.flush(); | ||||
return baos.toByteArray(); | return baos.toByteArray(); | ||||
} catch (FileNotFoundException e) { | } catch (FileNotFoundException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} finally { | } finally { | ||||
try { | try { | ||||
if (fileis != null) | if (fileis != null) | ||||
@@ -44,7 +44,7 @@ class FileLoade { | |||||
if (fileis != null) | if (fileis != null) | ||||
baos.close(); | baos.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} | } | ||||
} | } | ||||
LOGGER.error(fileis + "这个路径文件没有找到,请查询"); | LOGGER.error(fileis + "这个路径文件没有找到,请查询"); | ||||
@@ -43,7 +43,7 @@ public final class POICacheManager { | |||||
byte[] result = Arrays.copyOf(loadingCache.get(id), loadingCache.get(id).length); | byte[] result = Arrays.copyOf(loadingCache.get(id), loadingCache.get(id).length); | ||||
return new ByteArrayInputStream(result); | return new ByteArrayInputStream(result); | ||||
} catch (ExecutionException e) { | } catch (ExecutionException e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
@@ -219,7 +219,6 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(); | |||||
logger.error(e.getMessage(),e); | logger.error(e.getMessage(),e); | ||||
throw new ExcelExportException(ExcelExportEnum.EXPORT_ERROR, e.getCause()); | throw new ExcelExportException(ExcelExportEnum.EXPORT_ERROR, e.getCause()); | ||||
} | } | ||||
@@ -148,7 +148,7 @@ public final class ExcelExportOfTemplateUtil extends ExcelExportBase { | |||||
addDataToSheet(params, pojoClass, dataSet, wb.getSheetAt(0), wb); | addDataToSheet(params, pojoClass, dataSet, wb.getSheetAt(0), wb); | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
return null; | return null; | ||||
} | } | ||||
return wb; | return wb; | ||||
@@ -57,7 +57,7 @@ public class ParseWord07 { | |||||
.getNextPicNameNumber((Integer) isAndType[1]), obj.getWidth(), obj.getHeight()); | .getNextPicNameNumber((Integer) isAndType[1]), obj.getWidth(), obj.getHeight()); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
LOGGER.error(e.getMessage(), e.fillInStackTrace()); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} | } | ||||
} | } | ||||
@@ -1,13 +1,13 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
<classpath> | <classpath> | ||||
<classpathentry kind="src" output="target/test-classes" path="src/main/java"> | |||||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | |||||
<attributes> | <attributes> | ||||
<attribute name="optional" value="true"/> | <attribute name="optional" value="true"/> | ||||
<attribute name="maven.pomderived" value="true"/> | <attribute name="maven.pomderived" value="true"/> | ||||
</attributes> | </attributes> | ||||
</classpathentry> | </classpathentry> | ||||
<classpathentry kind="src" path="src/test"/> | <classpathentry kind="src" path="src/test"/> | ||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/main/resources"> | |||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | |||||
<attributes> | <attributes> | ||||
<attribute name="maven.pomderived" value="true"/> | <attribute name="maven.pomderived" value="true"/> | ||||
</attributes> | </attributes> | ||||
@@ -7,6 +7,7 @@ import javax.servlet.ServletOutputStream; | |||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
import org.jeecgframework.poi.excel.ExcelExportUtil; | import org.jeecgframework.poi.excel.ExcelExportUtil; | ||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams; | import org.jeecgframework.poi.excel.entity.TemplateExportParams; | ||||
@@ -25,6 +26,9 @@ public class JeecgTemplateExcelView extends AbstractView { | |||||
private static final String CONTENT_TYPE = "application/vnd.ms-excel"; | private static final String CONTENT_TYPE = "application/vnd.ms-excel"; | ||||
private static final String HSSF = ".xls"; | |||||
private static final String XSSF = ".xlsx"; | |||||
public JeecgTemplateExcelView() { | public JeecgTemplateExcelView() { | ||||
setContentType(CONTENT_TYPE); | setContentType(CONTENT_TYPE); | ||||
} | } | ||||
@@ -37,9 +41,19 @@ public class JeecgTemplateExcelView extends AbstractView { | |||||
@Override | @Override | ||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, | protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, | ||||
HttpServletResponse response) throws Exception { | HttpServletResponse response) throws Exception { | ||||
String codedFileName = "临时文件.xls"; | |||||
String codedFileName = "临时文件"; | |||||
Workbook workbook = ExcelExportUtil.exportExcel( | |||||
(TemplateExportParams) model.get(TemplateExcelConstants.PARAMS), | |||||
(Class<?>) model.get(TemplateExcelConstants.CLASS), | |||||
(List<?>) model.get(TemplateExcelConstants.LIST_DATA), | |||||
(Map<String, Object>) model.get(TemplateExcelConstants.MAP_DATA)); | |||||
if (model.containsKey(NormalExcelConstants.FILE_NAME)) { | if (model.containsKey(NormalExcelConstants.FILE_NAME)) { | ||||
codedFileName = (String) model.get(NormalExcelConstants.FILE_NAME) + ".xls"; | |||||
codedFileName = (String) model.get(NormalExcelConstants.FILE_NAME); | |||||
} | |||||
if (workbook instanceof HSSFWorkbook) { | |||||
codedFileName += HSSF; | |||||
} else { | |||||
codedFileName += XSSF; | |||||
} | } | ||||
if (isIE(request)) { | if (isIE(request)) { | ||||
codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8"); | codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8"); | ||||
@@ -47,11 +61,6 @@ public class JeecgTemplateExcelView extends AbstractView { | |||||
codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1"); | codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1"); | ||||
} | } | ||||
response.setHeader("content-disposition", "attachment;filename=" + codedFileName); | response.setHeader("content-disposition", "attachment;filename=" + codedFileName); | ||||
Workbook workbook = ExcelExportUtil.exportExcel( | |||||
(TemplateExportParams) model.get(TemplateExcelConstants.PARAMS), | |||||
(Class<?>) model.get(TemplateExcelConstants.CLASS), | |||||
(List<?>) model.get(TemplateExcelConstants.LIST_DATA), | |||||
(Map<String, Object>) model.get(TemplateExcelConstants.MAP_DATA)); | |||||
ServletOutputStream out = response.getOutputStream(); | ServletOutputStream out = response.getOutputStream(); | ||||
workbook.write(out); | workbook.write(out); | ||||
out.flush(); | out.flush(); | ||||
@@ -137,7 +137,33 @@ | |||||
<encoding>UTF-8</encoding> | <encoding>UTF-8</encoding> | ||||
</configuration> | </configuration> | ||||
</plugin> | </plugin> | ||||
<plugin> | |||||
<artifactId>maven-source-plugin</artifactId> | |||||
<version>2.1</version> | |||||
<configuration> | |||||
<attach>true</attach> | |||||
</configuration> | |||||
<executions> | |||||
<execution> | |||||
<phase>compile</phase> | |||||
<goals> | |||||
<goal>jar</goal> | |||||
</goals> | |||||
</execution> | |||||
</executions> | |||||
</plugin> | |||||
</plugins> | </plugins> | ||||
</build> | </build> | ||||
<distributionManagement> | |||||
<repository> | |||||
<id>postaop-common-release</id> | |||||
<url>http://192.168.1.99:8081/nexus/content/repositories/postaop-common-release/</url> | |||||
</repository> | |||||
<snapshotRepository> | |||||
<id>postaop-common-snapshot</id> | |||||
<url>http://192.168.1.99:8081/nexus/content/repositories/postaop-common-snapshot/</url> | |||||
</snapshotRepository> | |||||
</distributionManagement> | |||||
</project> | </project> |