POI 导入,判断 excel 中的空行
public boolean isRowEmpty(Row row) {
for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
Cell cell = row.getCell(c);
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
return false;
}
}
return true;
}
POI 导出,添加超链接
private void addHyperlink(Cell cell, Object val) {
CreationHelper createHelper = wb.getCreationHelper();
XSSFHyperlink link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL);
link.setAddress(val.toString());
cell.setHyperlink(link);
CellStyle linkStyle = wb.createCellStyle();
Font cellFont = wb.createFont();
cellFont.setUnderline((byte) 1);
cellFont.setColor(HSSFColor.BLUE.index);
linkStyle.setFont(cellFont);
cell.setCellStyle(linkStyle);
}