看文档 http://easypoi.mydoc.io/

步骤一

  • 字段上面开启超链接
    1
    2
    @Excel(name = "地址", isHyperlink = true)
    private String path;

步骤二

  • 实现拦截类

image.png

  • 代码实现
1
2
3
4
5
6
7
8
9
public class ExcelDataHandler extends ExcelDataHandlerDefaultImpl<Object> {
@Override
public Hyperlink getHyperlink(CreationHelper creationHelper, Object obj, String name, Object value) {
Hyperlink hyperlink = creationHelper.createHyperlink(HyperlinkType.URL);
hyperlink.setLabel(name);
hyperlink.setAddress((String) value);
return hyperlink;
}
}

Object为操作类

步骤三

  • 将拦截类加载导出方法
    1
    2
    3
    ExportParams exportParams = new ExportParams(title, sheetName);
    exportParams.setDataHandler(new ExcelDataHandler());
    ExportExcelUtil.exportExcel(list, Object.class, fileName, response, exportParams);

    Object操作模板

结束