上面 excelReader.read(new Sheet(1, 1, Object.class)); 方法报错
时间: 2024-03-08 16:47:24
浏览: 25
非常抱歉,我在之前的回答中犯了一个错误。EasyExcel库中的Sheet类确实是抽象的,不能直接实例化。正确的用法是使用它的Builder类来创建Sheet[对象](https://geek.csdn.net/educolumn/04c51611e4b730957464192e0307b82c?spm=1055.2569.3001.10083),如下所示:
```java
public st[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)c List<Object> readExcelToList(MultipartFile file) throws IOException {
List<Object> list = new ArrayList<>();
InputStream inputStream = file.[get](https://geek.csdn.net/educolumn/31aebce56f4ecc5451aac3a194ff6259?spm=1055.2569.3001.10083)InputStream();
ExcelReader excelReader = EasyExcel.read(inputStream, new AnalysisEventListener<Object>() {
@Override
public void invoke(Object data, AnalysisContext context) {
list.add(data);
@Override
public void doAfterAl[lan](https://geek.csdn.net/educolumn/2e627c1ce792f2bd6c896ec0221f0ac0?spm=1055.2569.3001.10083)alysed(AnalysisContext context) {
// 解析结束销毁不用的资源
try {
context.readWorkbookHolder().[get](https://geek.csdn.net/educolumn/31aebce56f4ecc5451aac3a194ff6259?spm=1055.2569.3001.10083)InputStream().close();
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)