hutool excel超链接
时间: 2023-08-09 08:07:33 浏览: 522
在Hutool Excel中,可以使用ExcelWriter的writeHyperlink方法来创建超链接。以下是一个示例代码:
```java
// 创建ExcelWriter对象
ExcelWriter writer = ExcelUtil.getWriter(true);
// 写入数据
writer.writeCellValue(0, 0, "导出Excel");
writer.writeHyperlink(0, 0, "http://localhost:8080/export", "导出Excel");
// 设置响应头信息
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("export.xlsx", "UTF-8"));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// 写出Excel文件
ServletOutputStream outputStream = response.getOutputStream();
writer.flush(outputStream, true);
writer.close();
IoUtil.close(outputStream);
```
在上述代码中,我们首先创建了一个ExcelWriter对象,然后使用writeCellValue方法写入文本数据,使用writeHyperlink方法创建超链接。最后,设置响应头信息,获取输出流,通过writer的flush方法将Excel文件写出到输出流中。
请注意,上述代码中的URL地址需要根据实际情况进行修改。
#### 引用[.reference_title]
- *1* [利用hutool工具类导出Excel表格](https://blog.csdn.net/iot_qizu/article/details/107601453)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [Hutool(Excel工具使用)](https://blog.csdn.net/qq_43230007/article/details/107216171)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文