@@ -49,8 +49,8 @@ import org.slf4j.LoggerFactory; | |||||
* @date 2014年6月17日 下午5:30:54 | * @date 2014年6月17日 下午5:30:54 | ||||
*/ | */ | ||||
public class ExcelExportServer extends ExcelExportBase { | public class ExcelExportServer extends ExcelExportBase { | ||||
private final static Logger logger = LoggerFactory.getLogger(ExcelExportServer.class); | |||||
private final static Logger LOGGER = LoggerFactory.getLogger(ExcelExportServer.class); | |||||
// 最大行数,超过自动多Sheet | // 最大行数,超过自动多Sheet | ||||
private int MAX_NUM = 60000; | private int MAX_NUM = 60000; | ||||
@@ -102,9 +102,9 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
public void createSheet(Workbook workbook, ExportParams entity, Class<?> pojoClass, | public void createSheet(Workbook workbook, ExportParams entity, Class<?> pojoClass, | ||||
Collection<?> dataSet) { | Collection<?> dataSet) { | ||||
if (logger.isDebugEnabled()) { | |||||
logger.debug("Excel export start ,class is {}", pojoClass); | |||||
logger.debug("Excel version is {}", entity.getType().equals(ExcelType.HSSF) ? "03" | |||||
if (LOGGER.isDebugEnabled()) { | |||||
LOGGER.debug("Excel export start ,class is {}", pojoClass); | |||||
LOGGER.debug("Excel version is {}", entity.getType().equals(ExcelType.HSSF) ? "03" | |||||
: "07"); | : "07"); | ||||
} | } | ||||
if (workbook == null || entity == null || pojoClass == null || dataSet == null) { | if (workbook == null || entity == null || pojoClass == null || dataSet == null) { | ||||
@@ -174,8 +174,8 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(); | |||||
logger.error(e.getMessage(), e); | |||||
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()); | ||||
} | } | ||||
} | } | ||||
@@ -183,8 +183,8 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
public void createSheetForMap(Workbook workbook, ExportParams entity, | public void createSheetForMap(Workbook workbook, ExportParams entity, | ||||
List<ExcelExportEntity> entityList, | List<ExcelExportEntity> entityList, | ||||
Collection<? extends Map<?, ?>> dataSet) { | Collection<? extends Map<?, ?>> dataSet) { | ||||
if (logger.isDebugEnabled()) { | |||||
logger.debug("Excel version is {}", entity.getType().equals(ExcelType.HSSF) ? "03" | |||||
if (LOGGER.isDebugEnabled()) { | |||||
LOGGER.debug("Excel version is {}", entity.getType().equals(ExcelType.HSSF) ? "03" | |||||
: "07"); | : "07"); | ||||
} | } | ||||
if (workbook == null || entity == null || entityList == null || dataSet == null) { | if (workbook == null || entity == null || entityList == null || dataSet == null) { | ||||
@@ -247,7 +247,7 @@ public class ExcelExportServer extends ExcelExportBase { | |||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
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()); | ||||
} | } | ||||
} | } | ||||
@@ -49,6 +49,8 @@ import org.jeecgframework.poi.excel.entity.params.MergeEntity; | |||||
import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | import org.jeecgframework.poi.excel.entity.vo.PoiBaseConstants; | ||||
import org.jeecgframework.poi.excel.export.styler.IExcelExportStyler; | import org.jeecgframework.poi.excel.export.styler.IExcelExportStyler; | ||||
import org.jeecgframework.poi.util.PoiPublicUtil; | import org.jeecgframework.poi.util.PoiPublicUtil; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
/** | /** | ||||
* 提供POI基础操作服务 | * 提供POI基础操作服务 | ||||
@@ -57,6 +59,8 @@ import org.jeecgframework.poi.util.PoiPublicUtil; | |||||
* @date 2014年6月17日 下午6:15:13 | * @date 2014年6月17日 下午6:15:13 | ||||
*/ | */ | ||||
public abstract class ExcelExportBase extends ExportBase { | public abstract class ExcelExportBase extends ExportBase { | ||||
private static final Logger LOGGER = LoggerFactory.getLogger(ExcelExportBase.class); | |||||
private int currentIndex = 0; | private int currentIndex = 0; | ||||
@@ -190,7 +194,7 @@ public abstract class ExcelExportBase extends ExportBase { | |||||
patriarch.createPicture(anchor, | patriarch.createPicture(anchor, | ||||
row.getSheet().getWorkbook().addPicture(value, getImageType(value))); | row.getSheet().getWorkbook().addPicture(value, getImageType(value))); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
e.printStackTrace(); | |||||
LOGGER.error(e.getMessage(),e); | |||||
} | } | ||||
} else { | } else { | ||||
byte[] value = (byte[]) (entity.getMethods() != null ? getFieldBySomeMethod( | byte[] value = (byte[]) (entity.getMethods() != null ? getFieldBySomeMethod( | ||||
@@ -62,7 +62,7 @@ public class CellValueServer { | |||||
} | } | ||||
Object result = null; | Object result = null; | ||||
// 日期格式比较特殊,和cell格式不一致 | // 日期格式比较特殊,和cell格式不一致 | ||||
if (xclass.equals("class java.util.Date")) { | |||||
if ("class java.util.Date".equals(xclass)) { | |||||
if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { | if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { | ||||
// 日期格式 | // 日期格式 | ||||
result = cell.getDateCellValue(); | result = cell.getDateCellValue(); | ||||
@@ -156,28 +156,28 @@ public class CellValueServer { | |||||
*/ | */ | ||||
private Object getValueByType(String xclass, Object result) { | private Object getValueByType(String xclass, Object result) { | ||||
try { | try { | ||||
if (xclass.equals("class java.util.Date")) { | |||||
if ("class java.util.Date".equals(xclass)) { | |||||
return result; | return result; | ||||
} | } | ||||
if (xclass.equals("class java.lang.Boolean") || xclass.equals("boolean")) { | |||||
if ("class java.lang.Boolean".equals(xclass) || "boolean".equals(xclass)) { | |||||
return Boolean.valueOf(String.valueOf(result)); | return Boolean.valueOf(String.valueOf(result)); | ||||
} | } | ||||
if (xclass.equals("class java.lang.Double") || xclass.equals("double")) { | |||||
if ("class java.lang.Double".equals(xclass) || "double".equals(xclass)) { | |||||
return Double.valueOf(String.valueOf(result)); | return Double.valueOf(String.valueOf(result)); | ||||
} | } | ||||
if (xclass.equals("class java.lang.Long") || xclass.equals("long")) { | |||||
if ("class java.lang.Long".equals(xclass) || "long".equals(xclass)) { | |||||
return Long.valueOf(String.valueOf(result)); | return Long.valueOf(String.valueOf(result)); | ||||
} | } | ||||
if (xclass.equals("class java.lang.Float") || xclass.equals("float")) { | |||||
if ("class java.lang.Float".equals(xclass) || "float".equals(xclass)) { | |||||
return Float.valueOf(String.valueOf(result)); | return Float.valueOf(String.valueOf(result)); | ||||
} | } | ||||
if (xclass.equals("class java.lang.Integer") || xclass.equals("int")) { | |||||
if ("class java.lang.Integer".equals(xclass) || "int".equals(xclass)) { | |||||
return Integer.valueOf(String.valueOf(result)); | return Integer.valueOf(String.valueOf(result)); | ||||
} | } | ||||
if (xclass.equals("class java.math.BigDecimal")) { | |||||
if ("class java.math.BigDecimal".equals(xclass)) { | |||||
return new BigDecimal(String.valueOf(result)); | return new BigDecimal(String.valueOf(result)); | ||||
} | } | ||||
if (xclass.equals("class java.lang.String")) { | |||||
if ("class java.lang.String".equals(xclass)) { | |||||
return String.valueOf(result); | return String.valueOf(result); | ||||
} | } | ||||
return result; | return result; | ||||
@@ -20,6 +20,7 @@ import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.apache.poi.xwpf.usermodel.XWPFDocument; | import org.apache.poi.xwpf.usermodel.XWPFDocument; | ||||
import org.apache.poi.xwpf.usermodel.XWPFFooter; | import org.apache.poi.xwpf.usermodel.XWPFFooter; | ||||
import org.apache.poi.xwpf.usermodel.XWPFHeader; | import org.apache.poi.xwpf.usermodel.XWPFHeader; | ||||
@@ -157,7 +158,7 @@ public class ParseWord07 { | |||||
for (int i = 0; i < paragraph.getRuns().size(); i++) { | for (int i = 0; i < paragraph.getRuns().size(); i++) { | ||||
run = paragraph.getRuns().get(i); | run = paragraph.getRuns().get(i); | ||||
text = run.getText(0); | text = run.getText(0); | ||||
if (text == null || text == "") { | |||||
if (StringUtils.isEmpty(text)) { | |||||
continue; | continue; | ||||
}// 如果为空或者""这种这继续循环跳过 | }// 如果为空或者""这种这继续循环跳过 | ||||
if (isfinde) { | if (isfinde) { | ||||
@@ -34,6 +34,8 @@ import org.jeecgframework.poi.exception.word.WordExportException; | |||||
import org.jeecgframework.poi.exception.word.enmus.WordExportEnum; | import org.jeecgframework.poi.exception.word.enmus.WordExportEnum; | ||||
import org.jeecgframework.poi.util.PoiPublicUtil; | import org.jeecgframework.poi.util.PoiPublicUtil; | ||||
import org.jeecgframework.poi.word.entity.params.ExcelListEntity; | import org.jeecgframework.poi.word.entity.params.ExcelListEntity; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
/** | /** | ||||
* 解析实体类对象 复用注解 | * 解析实体类对象 复用注解 | ||||
@@ -43,6 +45,8 @@ import org.jeecgframework.poi.word.entity.params.ExcelListEntity; | |||||
*/ | */ | ||||
public class ExcelEntityParse extends ExportBase { | public class ExcelEntityParse extends ExportBase { | ||||
private static final Logger LOGGER = LoggerFactory.getLogger(ExcelEntityParse.class); | |||||
private static void checkExcelParams(ExcelListEntity entity) { | private static void checkExcelParams(ExcelListEntity entity) { | ||||
if (entity.getList() == null || entity.getClazz() == null) { | if (entity.getList() == null || entity.getClazz() == null) { | ||||
throw new WordExportException(WordExportEnum.EXCEL_PARAMS_ERROR); | throw new WordExportException(WordExportEnum.EXCEL_PARAMS_ERROR); | ||||
@@ -172,7 +176,7 @@ public class ExcelEntityParse extends ExportBase { | |||||
index += createCells(index, t, excelParams, table, rowHeight); | index += createCells(index, t, excelParams, table, rowHeight); | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(); | |||||
LOGGER.error(e.getMessage(), e); | |||||
} | } | ||||
} | } | ||||