Skip to content

Commit

Permalink
日志格式化输出
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongd_Zhou committed Apr 18, 2022
1 parent 55ca1bb commit bdfb890
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions poi/src/main/java/cn/zm1001/util/poi/ExcelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.zm1001.util.common.StringUtils;
import cn.zm1001.util.poi.annotation.Excel;
import cn.zm1001.util.poi.annotation.Excels;
import cn.zm1001.util.poi.exception.ExcelException;
import cn.zm1001.util.poi.handler.ExcelHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
Expand Down Expand Up @@ -119,7 +120,7 @@ public List<T> importExcel(InputStream is, String sheetName, int titleNum) throw
// 若指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
if (null == sheet) {
throw new IOException("文件sheet不存在");
throw new ExcelException("文件sheet不存在");
}
List<T> list = new ArrayList<>();
// 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1
Expand Down Expand Up @@ -356,7 +357,7 @@ private String dataFormatHandlerAdapter(Object value, Excel excel) {
Method formatMethod = excel.handler().getMethod("format", Object.class, String[].class);
value = formatMethod.invoke(instance, value, excel.args());
} catch (Exception e) {
log.error("不能格式化数据 " + excel.handler(), e);
log.error("#dataFormatHandlerAdapter# ## ## 不能格式化数据 {}", excel.handler(), e);
}
return ObjectUtils.toStr(value);
}
Expand Down Expand Up @@ -560,7 +561,7 @@ private void exportExcel(OutputStream out) {
writeSheet();
wb.write(out);
} catch (Exception e) {
log.error("导出Excel异常{}", e.getMessage());
log.error("#exportExcel# ## ## 导出Excel异常", e);
} finally {
IOUtils.closeQuietly(wb);
IOUtils.closeQuietly(out);
Expand Down Expand Up @@ -747,7 +748,7 @@ private void addCell(Excel attr, Row row, T vo, Field field, int column) {
addStatisticsData(column, ObjectUtils.toStr(value), attr);
}
} catch (Exception e) {
log.error("导出Excel失败", e);
log.error("#addCell# ## ##导出Excel失败", e);
}
}

Expand Down

0 comments on commit bdfb890

Please sign in to comment.